File: pr82337.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (59 lines) | stat: -rw-r--r-- 2,389 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -passes=loop-idiom < %s | FileCheck %s

; The poison flags should be preserved, as no transform takes place.
define void @test(ptr %p.end, ptr %p.start) {
; CHECK-LABEL: define void @test(
; CHECK-SAME: ptr [[P_END:%.*]], ptr [[P_START:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[P_END_INT:%.*]] = ptrtoint ptr [[P_END]] to i64
; CHECK-NEXT:    [[P_START_INT:%.*]] = ptrtoint ptr [[P_START]] to i64
; CHECK-NEXT:    [[DIST:%.*]] = sub nuw i64 [[P_END_INT]], [[P_START_INT]]
; CHECK-NEXT:    [[LEN:%.*]] = lshr exact i64 [[DIST]], 5
; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr [[P_END]], [[P_START]]
; CHECK-NEXT:    br i1 [[CMP]], label [[EXIT:%.*]], label [[PREHEADER:%.*]]
; CHECK:       preheader:
; CHECK-NEXT:    br label [[LOOP:%.*]]
; CHECK:       loop:
; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[LEN]], [[PREHEADER]] ], [ [[IV_DEC:%.*]], [[LOOP]] ]
; CHECK-NEXT:    [[IV_NEG:%.*]] = sub nsw i64 0, [[IV]]
; CHECK-NEXT:    [[SRC:%.*]] = getelementptr inbounds [32 x i8], ptr [[P_END]], i64 [[IV_NEG]]
; CHECK-NEXT:    [[V:%.*]] = load <4 x i64>, ptr [[SRC]], align 8
; CHECK-NEXT:    [[DST:%.*]] = getelementptr inbounds [32 x i8], ptr [[P_START]], i64 [[IV_NEG]]
; CHECK-NEXT:    store <4 x i64> [[V]], ptr [[DST]], align 8
; CHECK-NEXT:    [[IV_DEC]] = add i64 [[IV]], -1
; CHECK-NEXT:    [[CMP2:%.*]] = icmp eq i64 [[IV_DEC]], 0
; CHECK-NEXT:    br i1 [[CMP2]], label [[LOOP_EXIT:%.*]], label [[LOOP]]
; CHECK:       loop.exit:
; CHECK-NEXT:    br label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  %p.end.int = ptrtoint ptr %p.end to i64
  %p.start.int = ptrtoint ptr %p.start to i64
  %dist = sub nuw i64 %p.end.int, %p.start.int
  %len = lshr exact i64 %dist, 5
  %cmp = icmp eq ptr %p.end, %p.start
  br i1 %cmp, label %exit, label %preheader

preheader:
  br label %loop

loop:
  %iv = phi i64 [ %len, %preheader ], [ %iv.dec, %loop ]
  %iv.neg = sub nsw i64 0, %iv
  %src = getelementptr inbounds [32 x i8], ptr %p.end, i64 %iv.neg
  %v = load <4 x i64>, ptr %src, align 8
  %dst = getelementptr inbounds [32 x i8], ptr %p.start, i64 %iv.neg
  store <4 x i64> %v, ptr %dst, align 8
  %iv.dec = add i64 %iv, -1
  %cmp2 = icmp eq i64 %iv.dec, 0
  br i1 %cmp2, label %loop.exit, label %loop

loop.exit:
  br label %exit

exit:
  ret void
}