xref: /llvm-project/llvm/test/Transforms/ConstraintElimination/geps-128-bit-pointers.ll (revision e143e52c2201b689d2de39394f059f8ef1a27fc4)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
3
4target datalayout = "p:128:64"
5
6; Test for 128 bit pointers. At the moment, constraints only support signed i64 offsets.
7define i1 @gep_decomp_large_index_63_bits(ptr %a) {
8; CHECK-LABEL: @gep_decomp_large_index_63_bits(
9; CHECK-NEXT:  entry:
10; CHECK-NEXT:    [[GEP_1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 9223372036854775804
11; CHECK-NEXT:    [[GEP_2:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 9223372036854775805
12; CHECK-NEXT:    [[NE:%.*]] = icmp ne ptr [[GEP_1]], [[GEP_2]]
13; CHECK-NEXT:    call void @llvm.assume(i1 [[NE]])
14; CHECK-NEXT:    [[CMP_ULE:%.*]] = icmp ule ptr [[GEP_1]], [[GEP_2]]
15; CHECK-NEXT:    [[CMP_UGE:%.*]] = icmp uge ptr [[GEP_1]], [[GEP_2]]
16; CHECK-NEXT:    [[RES:%.*]] = xor i1 [[CMP_ULE]], [[CMP_ULE]]
17; CHECK-NEXT:    ret i1 [[RES]]
18;
19entry:
20  %gep.1 = getelementptr inbounds i64, ptr %a, i64 9223372036854775804
21  %gep.2 = getelementptr inbounds i64, ptr %a, i64 9223372036854775805
22  %ne = icmp ne ptr %gep.1, %gep.2
23  call void @llvm.assume(i1 %ne)
24  %cmp.ule = icmp ule ptr %gep.1, %gep.2
25  %cmp.uge = icmp uge ptr %gep.1, %gep.2
26  %res = xor i1 %cmp.ule, %cmp.ule
27  ret i1 %res
28}
29
30define i1 @gep_decomp_large_index_67_bits(ptr %a) {
31; CHECK-LABEL: @gep_decomp_large_index_67_bits(
32; CHECK-NEXT:  entry:
33; CHECK-NEXT:    [[GEP_1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i128 147573952589676412928
34; CHECK-NEXT:    [[GEP_2:%.*]] = getelementptr inbounds i64, ptr [[A]], i128 147573952589676412929
35; CHECK-NEXT:    [[NE:%.*]] = icmp ne ptr [[GEP_1]], [[GEP_2]]
36; CHECK-NEXT:    call void @llvm.assume(i1 [[NE]])
37; CHECK-NEXT:    [[CMP_ULE:%.*]] = icmp ule ptr [[GEP_1]], [[GEP_2]]
38; CHECK-NEXT:    [[CMP_UGE:%.*]] = icmp uge ptr [[GEP_1]], [[GEP_2]]
39; CHECK-NEXT:    [[RES:%.*]] = xor i1 [[CMP_ULE]], [[CMP_UGE]]
40; CHECK-NEXT:    ret i1 [[RES]]
41;
42entry:
43  %gep.1 = getelementptr inbounds i64, ptr %a, i128 147573952589676412928
44  %gep.2 = getelementptr inbounds i64, ptr %a, i128 147573952589676412929
45  %ne = icmp ne ptr %gep.1, %gep.2
46  call void @llvm.assume(i1 %ne)
47  %cmp.ule = icmp ule ptr %gep.1, %gep.2
48  %cmp.uge = icmp uge ptr %gep.1, %gep.2
49  %res = xor i1 %cmp.ule, %cmp.uge
50  ret i1 %res
51}
52
53declare void @llvm.assume(i1)
54