[llvm] e143e52 - [ConstraintElimination] Add tests with 128 bit pointers.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 11:49:49 PDT 2022
Author: Florian Hahn
Date: 2022-10-12T19:49:29+01:00
New Revision: e143e52c2201b689d2de39394f059f8ef1a27fc4
URL: https://github.com/llvm/llvm-project/commit/e143e52c2201b689d2de39394f059f8ef1a27fc4
DIFF: https://github.com/llvm/llvm-project/commit/e143e52c2201b689d2de39394f059f8ef1a27fc4.diff
LOG: [ConstraintElimination] Add tests with 128 bit pointers.
Added:
llvm/test/Transforms/ConstraintElimination/geps-128-bit-pointers.ll
Modified:
llvm/test/Transforms/ConstraintElimination/large-constant-ints.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/geps-128-bit-pointers.ll b/llvm/test/Transforms/ConstraintElimination/geps-128-bit-pointers.ll
new file mode 100644
index 0000000000000..c790a62a30c52
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/geps-128-bit-pointers.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
+
+target datalayout = "p:128:64"
+
+; Test for 128 bit pointers. At the moment, constraints only support signed i64 offsets.
+define i1 @gep_decomp_large_index_63_bits(ptr %a) {
+; CHECK-LABEL: @gep_decomp_large_index_63_bits(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 9223372036854775804
+; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 9223372036854775805
+; CHECK-NEXT: [[NE:%.*]] = icmp ne ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[NE]])
+; CHECK-NEXT: [[CMP_ULE:%.*]] = icmp ule ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: [[CMP_UGE:%.*]] = icmp uge ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: [[RES:%.*]] = xor i1 [[CMP_ULE]], [[CMP_ULE]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %gep.1 = getelementptr inbounds i64, ptr %a, i64 9223372036854775804
+ %gep.2 = getelementptr inbounds i64, ptr %a, i64 9223372036854775805
+ %ne = icmp ne ptr %gep.1, %gep.2
+ call void @llvm.assume(i1 %ne)
+ %cmp.ule = icmp ule ptr %gep.1, %gep.2
+ %cmp.uge = icmp uge ptr %gep.1, %gep.2
+ %res = xor i1 %cmp.ule, %cmp.ule
+ ret i1 %res
+}
+
+define i1 @gep_decomp_large_index_67_bits(ptr %a) {
+; CHECK-LABEL: @gep_decomp_large_index_67_bits(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i128 147573952589676412928
+; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i64, ptr [[A]], i128 147573952589676412929
+; CHECK-NEXT: [[NE:%.*]] = icmp ne ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[NE]])
+; CHECK-NEXT: [[CMP_ULE:%.*]] = icmp ule ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: [[CMP_UGE:%.*]] = icmp uge ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: [[RES:%.*]] = xor i1 [[CMP_ULE]], [[CMP_UGE]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %gep.1 = getelementptr inbounds i64, ptr %a, i128 147573952589676412928
+ %gep.2 = getelementptr inbounds i64, ptr %a, i128 147573952589676412929
+ %ne = icmp ne ptr %gep.1, %gep.2
+ call void @llvm.assume(i1 %ne)
+ %cmp.ule = icmp ule ptr %gep.1, %gep.2
+ %cmp.uge = icmp uge ptr %gep.1, %gep.2
+ %res = xor i1 %cmp.ule, %cmp.uge
+ ret i1 %res
+}
+
+declare void @llvm.assume(i1)
diff --git a/llvm/test/Transforms/ConstraintElimination/large-constant-ints.ll b/llvm/test/Transforms/ConstraintElimination/large-constant-ints.ll
index ec485f424c6b0..411a0fe05502a 100644
--- a/llvm/test/Transforms/ConstraintElimination/large-constant-ints.ll
+++ b/llvm/test/Transforms/ConstraintElimination/large-constant-ints.ll
@@ -304,8 +304,8 @@ define i1 @add_minus_one_decomp_recursive() {
ret i1 %cmp
}
-define i1 @gep_decomp_large_index(ptr %a) {
-; CHECK-LABEL: @gep_decomp_large_index(
+define i1 @gep_decomp_large_index_31_bits(ptr %a) {
+; CHECK-LABEL: @gep_decomp_large_index_31_bits(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 2147483646
; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 2147483647
@@ -327,4 +327,27 @@ entry:
ret i1 %res
}
+define i1 @gep_decomp_large_index_63_bits(ptr %a) {
+; CHECK-LABEL: @gep_decomp_large_index_63_bits(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 9223372036854775804
+; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 9223372036854775805
+; CHECK-NEXT: [[NE:%.*]] = icmp ne ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[NE]])
+; CHECK-NEXT: [[CMP_ULE:%.*]] = icmp ule ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: [[CMP_UGE:%.*]] = icmp uge ptr [[GEP_1]], [[GEP_2]]
+; CHECK-NEXT: [[RES:%.*]] = xor i1 [[CMP_ULE]], [[CMP_ULE]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+entry:
+ %gep.1 = getelementptr inbounds i64, ptr %a, i64 9223372036854775804
+ %gep.2 = getelementptr inbounds i64, ptr %a, i64 9223372036854775805
+ %ne = icmp ne ptr %gep.1, %gep.2
+ call void @llvm.assume(i1 %ne)
+ %cmp.ule = icmp ule ptr %gep.1, %gep.2
+ %cmp.uge = icmp uge ptr %gep.1, %gep.2
+ %res = xor i1 %cmp.ule, %cmp.ule
+ ret i1 %res
+}
+
declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list