1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -passes=loop-versioning -S < %s | FileCheck %s
4 ; NB: addrspaces 10-13 are non-integral
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12:13"
7 ; This matches the test case from PR38290
8 ; Check that we expand the SCEV predicate check using GEP, rather
11 %jl_value_t = type opaque
12 %jl_array_t = type { ptr addrspace(13), i64, i16, i16, i32 }
14 declare i64 @julia_steprange_last_4949()
16 define void @wrapping_ptr_nonint_addrspace(ptr %arg) {
17 ; CHECK-LABEL: define void @wrapping_ptr_nonint_addrspace(
18 ; CHECK-SAME: ptr [[ARG:%.*]]) {
19 ; CHECK-NEXT: [[LOOP_LVER_CHECK:.*:]]
20 ; CHECK-NEXT: [[LOAD0:%.*]] = load ptr addrspace(10), ptr [[ARG]], align 8
21 ; CHECK-NEXT: [[LOAD1:%.*]] = load i32, ptr inttoptr (i64 12 to ptr), align 4
22 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[LOAD1]]
23 ; CHECK-NEXT: [[CALL:%.*]] = call i64 @julia_steprange_last_4949()
24 ; CHECK-NEXT: [[CAST0:%.*]] = addrspacecast ptr addrspace(10) [[LOAD0]] to ptr addrspace(11)
25 ; CHECK-NEXT: [[LOAD2:%.*]] = load ptr addrspace(10), ptr addrspace(11) [[CAST0]], align 8
26 ; CHECK-NEXT: [[CAST1:%.*]] = addrspacecast ptr addrspace(10) [[LOAD2]] to ptr addrspace(11)
27 ; CHECK-NEXT: [[LOAD3:%.*]] = load ptr addrspace(13), ptr addrspace(11) [[CAST1]], align 8
28 ; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[SUB]] to i64
29 ; CHECK-NEXT: [[TMP0:%.*]] = shl i64 [[CALL]], 2
30 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i64 [[SEXT]], 2
31 ; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP0]], [[TMP1]]
32 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[TMP2]], -4
33 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr addrspace(13) [[LOAD3]], i64 [[TMP3]]
34 ; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr addrspace(13) [[LOAD3]], i64 [[TMP1]]
35 ; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[TMP0]], -4
36 ; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr addrspace(13) [[LOAD3]], i64 [[TMP4]]
37 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr addrspace(13) [[SCEVGEP]], [[LOAD3]]
38 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr addrspace(13) [[SCEVGEP2]], [[SCEVGEP1]]
39 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
40 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label %[[LOOP_PH_LVER_ORIG:.*]], label %[[LOOP_PH:.*]]
41 ; CHECK: [[LOOP_PH_LVER_ORIG]]:
42 ; CHECK-NEXT: br label %[[LOOP_LVER_ORIG:.*]]
43 ; CHECK: [[LOOP_LVER_ORIG]]:
44 ; CHECK-NEXT: [[VALUE_PHI3_LVER_ORIG:%.*]] = phi i64 [ 0, %[[LOOP_PH_LVER_ORIG]] ], [ [[ADD0_LVER_ORIG:%.*]], %[[LOOP_LVER_ORIG]] ]
45 ; CHECK-NEXT: [[ADD0_LVER_ORIG]] = add i64 [[VALUE_PHI3_LVER_ORIG]], -1
46 ; CHECK-NEXT: [[GEP0_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr addrspace(13) [[LOAD3]], i64 [[ADD0_LVER_ORIG]]
47 ; CHECK-NEXT: [[LOAD4_LVER_ORIG:%.*]] = load i32, ptr addrspace(13) [[GEP0_LVER_ORIG]], align 4
48 ; CHECK-NEXT: [[ADD1_LVER_ORIG:%.*]] = add i64 [[ADD0_LVER_ORIG]], [[SEXT]]
49 ; CHECK-NEXT: [[GEP1_LVER_ORIG:%.*]] = getelementptr inbounds i32, ptr addrspace(13) [[LOAD3]], i64 [[ADD1_LVER_ORIG]]
50 ; CHECK-NEXT: store i32 [[LOAD4_LVER_ORIG]], ptr addrspace(13) [[GEP1_LVER_ORIG]], align 4
51 ; CHECK-NEXT: [[CMP_LVER_ORIG:%.*]] = icmp eq i64 [[VALUE_PHI3_LVER_ORIG]], [[CALL]]
52 ; CHECK-NEXT: br i1 [[CMP_LVER_ORIG]], label %[[EXIT_LOOPEXIT:.*]], label %[[LOOP_LVER_ORIG]]
54 ; CHECK-NEXT: br label %[[LOOP:.*]]
56 ; CHECK-NEXT: [[VALUE_PHI3:%.*]] = phi i64 [ 0, %[[LOOP_PH]] ], [ [[ADD0:%.*]], %[[LOOP]] ]
57 ; CHECK-NEXT: [[ADD0]] = add i64 [[VALUE_PHI3]], -1
58 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i32, ptr addrspace(13) [[LOAD3]], i64 [[ADD0]]
59 ; CHECK-NEXT: [[LOAD4:%.*]] = load i32, ptr addrspace(13) [[GEP0]], align 4, !alias.scope [[META0:![0-9]+]]
60 ; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[ADD0]], [[SEXT]]
61 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr addrspace(13) [[LOAD3]], i64 [[ADD1]]
62 ; CHECK-NEXT: store i32 [[LOAD4]], ptr addrspace(13) [[GEP1]], align 4, !alias.scope [[META3:![0-9]+]], !noalias [[META0]]
63 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[VALUE_PHI3]], [[CALL]]
64 ; CHECK-NEXT: br i1 [[CMP]], label %[[EXIT_LOOPEXIT3:.*]], label %[[LOOP]]
65 ; CHECK: [[EXIT_LOOPEXIT]]:
66 ; CHECK-NEXT: br label %[[EXIT:.*]]
67 ; CHECK: [[EXIT_LOOPEXIT3]]:
68 ; CHECK-NEXT: br label %[[EXIT]]
70 ; CHECK-NEXT: ret void
73 %load0 = load ptr addrspace(10), ptr %arg, align 8
74 %load1 = load i32, ptr inttoptr (i64 12 to ptr), align 4
75 %sub = sub i32 0, %load1
76 %call = call i64 @julia_steprange_last_4949()
77 %cast0 = addrspacecast ptr addrspace(10) %load0 to ptr addrspace(11)
78 %load2 = load ptr addrspace(10), ptr addrspace(11) %cast0, align 8
79 %cast1 = addrspacecast ptr addrspace(10) %load2 to ptr addrspace(11)
80 %load3 = load ptr addrspace(13), ptr addrspace(11) %cast1, align 8
81 %sext = sext i32 %sub to i64
85 %value_phi3 = phi i64 [ 0, %top ], [ %add0, %loop ]
86 %add0 = add i64 %value_phi3, -1
87 %gep0 = getelementptr inbounds i32, ptr addrspace(13) %load3, i64 %add0
88 %load4 = load i32, ptr addrspace(13) %gep0, align 4
89 %add1 = add i64 %add0, %sext
90 %gep1 = getelementptr inbounds i32, ptr addrspace(13) %load3, i64 %add1
91 store i32 %load4, ptr addrspace(13) %gep1, align 4
92 %cmp = icmp eq i64 %value_phi3, %call
93 br i1 %cmp, label %exit, label %loop
99 ; CHECK: [[META0]] = !{[[META1:![0-9]+]]}
100 ; CHECK: [[META1]] = distinct !{[[META1]], [[META2:![0-9]+]]}
101 ; CHECK: [[META2]] = distinct !{[[META2]], !"LVerDomain"}
102 ; CHECK: [[META3]] = !{[[META4:![0-9]+]]}
103 ; CHECK: [[META4]] = distinct !{[[META4]], [[META2]]}