1 ; RUN: opt -passes=loop-versioning -S < %s | FileCheck %s -check-prefix=LV
3 ; NB: addrspaces 10-13 are non-integral
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12:13"
6 ; This matches the test case from PR38290
7 ; Check that we expand the SCEV predicate check using GEP, rather
10 %jl_value_t = type opaque
11 %jl_array_t = type { ptr addrspace(13), i64, i16, i16, i32 }
13 declare i64 @julia_steprange_last_4949()
15 define void @"japi1_align!_9477"(ptr %arg) {
16 ; LV-LAVEL: L26.lver.check
17 ; LV: [[OFMul:%[^ ]*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[Step:%[^ ]*]])
18 ; LV-NEXT: [[OFMulResult:%[^ ]*]] = extractvalue { i64, i1 } [[OFMul]], 0
19 ; LV-NEXT: [[OFMulOverflow:%[^ ]*]] = extractvalue { i64, i1 } [[OFMul]], 1
20 ; LV: [[OFNegMulResult:%[^ ]*]] = sub i64 0, [[OFMulResult]]
21 ; LV-NEXT: [[NegGEP:%[^ ]*]] = getelementptr i8, ptr addrspace(13) [[Base:%[^ ]*]], i64 [[OFNegMulResult]]
22 ; LV-NEXT: icmp ugt ptr addrspace(13) [[NegGEP]], [[Base]]
26 %tmp = load ptr addrspace(10), ptr %arg, align 8
27 %tmp1 = load i32, ptr inttoptr (i64 12 to ptr), align 4
28 %tmp2 = sub i32 0, %tmp1
29 %tmp3 = call i64 @julia_steprange_last_4949()
30 %tmp4 = addrspacecast ptr addrspace(10) %tmp to ptr addrspace(11)
31 %tmp6 = load ptr addrspace(10), ptr addrspace(11) %tmp4, align 8
32 %tmp7 = addrspacecast ptr addrspace(10) %tmp6 to ptr addrspace(11)
33 %tmp9 = load ptr addrspace(13), ptr addrspace(11) %tmp7, align 8
34 %tmp10 = sext i32 %tmp2 to i64
38 %value_phi3 = phi i64 [ 0, %top ], [ %tmp11, %L26 ]
39 %tmp11 = add i64 %value_phi3, -1
40 %tmp12 = getelementptr inbounds i32, ptr addrspace(13) %tmp9, i64 %tmp11
41 %tmp13 = load i32, ptr addrspace(13) %tmp12, align 4
42 %tmp14 = add i64 %tmp11, %tmp10
43 %tmp15 = getelementptr inbounds i32, ptr addrspace(13) %tmp9, i64 %tmp14
44 store i32 %tmp13, ptr addrspace(13) %tmp15, align 4
45 %tmp16 = icmp eq i64 %value_phi3, %tmp3
46 br i1 %tmp16, label %L45, label %L26