1 ; RUN: opt -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 { i8 addrspace(13)*, i64, i16, i16, i32 }
13 declare i64 @julia_steprange_last_4949()
15 define void @"japi1_align!_9477"(%jl_value_t addrspace(10)** %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-NEXT: [[PosGEP:%[^ ]*]] = getelementptr i32, i32 addrspace(13)* [[Base:%[^ ]*]], i64 [[Step]]
21 ; LV-NEXT: [[NegGEP:%[^ ]*]] = getelementptr i32, i32 addrspace(13)* [[Base]], i64 [[NegStep:%[^ ]*]]
22 ; LV-NEXT: icmp ugt i32 addrspace(13)* [[NegGEP]], [[Base]]
23 ; LV-NEXT: icmp ult i32 addrspace(13)* [[PosGEP]], [[Base]]
27 %tmp = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %arg, align 8
28 %tmp1 = load i32, i32* inttoptr (i64 12 to i32*), align 4
29 %tmp2 = sub i32 0, %tmp1
30 %tmp3 = call i64 @julia_steprange_last_4949()
31 %tmp4 = addrspacecast %jl_value_t addrspace(10)* %tmp to %jl_value_t addrspace(11)*
32 %tmp5 = bitcast %jl_value_t addrspace(11)* %tmp4 to %jl_value_t addrspace(10)* addrspace(11)*
33 %tmp6 = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)* addrspace(11)* %tmp5, align 8
34 %tmp7 = addrspacecast %jl_value_t addrspace(10)* %tmp6 to %jl_value_t addrspace(11)*
35 %tmp8 = bitcast %jl_value_t addrspace(11)* %tmp7 to i32 addrspace(13)* addrspace(11)*
36 %tmp9 = load i32 addrspace(13)*, i32 addrspace(13)* addrspace(11)* %tmp8, align 8
37 %tmp10 = sext i32 %tmp2 to i64
41 %value_phi3 = phi i64 [ 0, %top ], [ %tmp11, %L26 ]
42 %tmp11 = add i64 %value_phi3, -1
43 %tmp12 = getelementptr inbounds i32, i32 addrspace(13)* %tmp9, i64 %tmp11
44 %tmp13 = load i32, i32 addrspace(13)* %tmp12, align 4
45 %tmp14 = add i64 %tmp11, %tmp10
46 %tmp15 = getelementptr inbounds i32, i32 addrspace(13)* %tmp9, i64 %tmp14
47 store i32 %tmp13, i32 addrspace(13)* %tmp15, align 4
48 %tmp16 = icmp eq i64 %value_phi3, %tmp3
49 br i1 %tmp16, label %L45, label %L26