[llvm] 802d21c - [ConstraintElimination] Add initial tests.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 06:28:01 PDT 2020
Author: Florian Hahn
Date: 2020-09-15T14:27:42+01:00
New Revision: 802d21cdf08ea43d5c32924ac29c44b00c4a841f
URL: https://github.com/llvm/llvm-project/commit/802d21cdf08ea43d5c32924ac29c44b00c4a841f
DIFF: https://github.com/llvm/llvm-project/commit/802d21cdf08ea43d5c32924ac29c44b00c4a841f.diff
LOG: [ConstraintElimination] Add initial tests.
Added:
llvm/test/Transforms/ConstraintElimination/dom.ll
llvm/test/Transforms/ConstraintElimination/geps.2d.ll
llvm/test/Transforms/ConstraintElimination/geps.ll
llvm/test/Transforms/ConstraintElimination/i128.ll
llvm/test/Transforms/ConstraintElimination/loops.ll
llvm/test/Transforms/ConstraintElimination/mixed.ll
llvm/test/Transforms/ConstraintElimination/uge.ll
llvm/test/Transforms/ConstraintElimination/ugt-ule.ll
llvm/test/Transforms/ConstraintElimination/ule.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/dom.ll b/llvm/test/Transforms/ConstraintElimination/dom.ll
new file mode 100644
index 0000000000000..a6b8629bed78a
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/dom.ll
@@ -0,0 +1,136 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+; Test cases where both the true and false successors reach the same block,
+; dominated by one of them.
+
+declare void @use(i1)
+
+define i32 @test1(i32 %x) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: br label [[BB2]]
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp ule i32 %x, 10
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %c.2 = icmp ule i32 %x, 10
+ call void @use(i1 %c.2)
+ br label %bb2
+
+bb2:
+ %c.3 = icmp ugt i32 %x, 10
+ call void @use(i1 %c.3)
+ ret i32 20
+}
+
+
+define i32 @test2(i32 %x) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB2:%.*]], label [[BB1:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: ret i32 20
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: br label [[BB1]]
+;
+entry:
+ %c.1 = icmp ule i32 %x, 10
+ br i1 %c.1, label %bb2, label %bb1
+
+bb1:
+ %c.2 = icmp ugt i32 %x, 10
+ call void @use(i1 %c.2)
+ ret i32 20
+
+bb2:
+ %c.3 = icmp ule i32 %x, 10
+ call void @use(i1 %c.3)
+ br label %bb1
+}
+
+
+; Test cases where the true/false successors are not domianted by the conditional branching block.
+define i32 @test3(i32 %x, i1 %c) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[BB_COND:%.*]], label [[BB1:%.*]]
+; CHECK: bb.cond:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: ret i32 10
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ br i1 %c, label %bb.cond, label %bb1
+
+bb.cond:
+ %c.1 = icmp ule i32 %x, 10
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %c.2 = icmp ule i32 %x, 10
+ call void @use(i1 %c.2)
+ ret i32 10
+
+bb2:
+ %c.3 = icmp ugt i32 %x, 10
+ call void @use(i1 %c.3)
+ ret i32 20
+}
+
+define i32 @test4(i32 %x, i1 %c) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[BB_COND:%.*]], label [[BB2:%.*]]
+; CHECK: bb.cond:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: ret i32 10
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ br i1 %c, label %bb.cond, label %bb2
+
+bb.cond:
+ %c.1 = icmp ule i32 %x, 10
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %c.2 = icmp ule i32 %x, 10
+ call void @use(i1 %c.2)
+ ret i32 10
+
+bb2:
+ %c.3 = icmp ugt i32 %x, 10
+ call void @use(i1 %c.3)
+ ret i32 20
+}
diff --git a/llvm/test/Transforms/ConstraintElimination/geps.2d.ll b/llvm/test/Transforms/ConstraintElimination/geps.2d.ll
new file mode 100644
index 0000000000000..bb24514404414
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/geps.2d.ll
@@ -0,0 +1,134 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+define void @test.not.uge.ult([10 x i8]* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.ult(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 10, i64 0
+; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8* [[START_0]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_0]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
+ %c.1 = icmp uge i8* %add.ptr.i, %high
+ br i1 %c.1, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 10, i64 0
+ %c.0 = icmp ult i8* %start.0, %high
+ call void @use(i1 %c.0)
+ ret void
+}
+
+define void @test.not.uge.ule([10 x i8]* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.ule(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
+; CHECK-NEXT: [[C:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 10, i64 0
+; CHECK-NEXT: [[C_0:%.*]] = icmp ule i8* [[START_0]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_0]])
+; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 2, i64 1
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[START_1]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_1]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
+ %c = icmp uge i8* %add.ptr.i, %high
+ br i1 %c, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 10, i64 0
+ %c.0 = icmp ule i8* %start.0, %high
+ call void @use(i1 %c.0)
+ %start.1 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 2, i64 1
+ %c.1 = icmp ule i8* %start.1, %high
+ call void @use(i1 %c.1)
+ ret void
+}
+
+define void @test.not.uge.ugt([10 x i8]* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.ugt(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
+; CHECK-NEXT: [[C:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 3, i64 0
+; CHECK-NEXT: [[C_0:%.*]] = icmp ugt i8* [[START_0]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_0]])
+; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 3, i64 1
+; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8* [[START_1]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_1]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
+ %c = icmp uge i8* %add.ptr.i, %high
+ br i1 %c, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 3, i64 0
+ %c.0 = icmp ugt i8* %start.0, %high
+ call void @use(i1 %c.0)
+
+ %start.1 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 3, i64 1
+ %c.1 = icmp ugt i8* %start.1, %high
+ call void @use(i1 %c.1)
+ ret void
+}
+
+define void @test.not.uge.uge([10 x i8]* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.uge(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 3, i64 0
+; CHECK-NEXT: [[C_0:%.*]] = icmp uge i8* [[START_0]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_0]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
+ %c.1 = icmp uge i8* %add.ptr.i, %high
+ br i1 %c.1, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 3, i64 0
+ %c.0 = icmp uge i8* %start.0, %high
+ call void @use(i1 %c.0)
+
+ ret void
+}
+
+declare void @use(i1)
diff --git a/llvm/test/Transforms/ConstraintElimination/geps.ll b/llvm/test/Transforms/ConstraintElimination/geps.ll
new file mode 100644
index 0000000000000..0e36ebf07f0f4
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/geps.ll
@@ -0,0 +1,332 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+define i32 @test.ult(i32* readonly %src, i32* readnone %min, i32* readnone %max) {
+; CHECK-LABEL: @test.ult(
+; CHECK-NEXT: check.0.min:
+; CHECK-NEXT: [[C_MIN_0:%.*]] = icmp ult i32* [[SRC:%.*]], [[MIN:%.*]]
+; CHECK-NEXT: br i1 [[C_MIN_0]], label [[TRAP:%.*]], label [[CHECK_0_MAX:%.*]]
+; CHECK: trap:
+; CHECK-NEXT: ret i32 10
+; CHECK: check.0.max:
+; CHECK-NEXT: [[C_MAX_0:%.*]] = icmp ult i32* [[SRC]], [[MAX:%.*]]
+; CHECK-NEXT: br i1 [[C_MAX_0]], label [[CHECK_3_MIN:%.*]], label [[TRAP]]
+; CHECK: check.3.min:
+; CHECK-NEXT: [[L0:%.*]] = load i32, i32* [[SRC]], align 4
+; CHECK-NEXT: [[ADD_PTR_I36:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 3
+; CHECK-NEXT: [[C_3_MIN:%.*]] = icmp ult i32* [[ADD_PTR_I36]], [[MIN]]
+; CHECK-NEXT: br i1 [[C_3_MIN]], label [[TRAP]], label [[CHECK_3_MAX:%.*]]
+; CHECK: check.3.max:
+; CHECK-NEXT: [[C_3_MAX:%.*]] = icmp ult i32* [[ADD_PTR_I36]], [[MAX]]
+; CHECK-NEXT: br i1 [[C_3_MAX]], label [[CHECK_1_MIN:%.*]], label [[TRAP]]
+; CHECK: check.1.min:
+; CHECK-NEXT: [[L1:%.*]] = load i32, i32* [[ADD_PTR_I36]], align 4
+; CHECK-NEXT: [[ADD_PTR_I29:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 1
+; CHECK-NEXT: [[C_1_MIN:%.*]] = icmp ult i32* [[ADD_PTR_I29]], [[MIN]]
+; CHECK-NEXT: br i1 [[C_1_MIN]], label [[TRAP]], label [[CHECK_1_MAX:%.*]]
+; CHECK: check.1.max:
+; CHECK-NEXT: [[C_1_MAX:%.*]] = icmp ult i32* [[ADD_PTR_I29]], [[MAX]]
+; CHECK-NEXT: br i1 [[C_1_MAX]], label [[CHECK_2_MIN:%.*]], label [[TRAP]]
+; CHECK: check.2.min:
+; CHECK-NEXT: [[L2:%.*]] = load i32, i32* [[ADD_PTR_I29]], align 4
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 2
+; CHECK-NEXT: [[C_2_MIN:%.*]] = icmp ult i32* [[ADD_PTR_I]], [[MIN]]
+; CHECK-NEXT: br i1 [[C_2_MIN]], label [[TRAP]], label [[CHECK_2_MAX:%.*]]
+; CHECK: check.2.max:
+; CHECK-NEXT: [[C_2_MAX:%.*]] = icmp ult i32* [[ADD_PTR_I]], [[MAX]]
+; CHECK-NEXT: br i1 [[C_2_MAX]], label [[EXIT:%.*]], label [[TRAP]]
+; CHECK: exit:
+; CHECK-NEXT: [[L3:%.*]] = load i32, i32* [[ADD_PTR_I]], align 4
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[L1]], [[L0]]
+; CHECK-NEXT: [[ADD8:%.*]] = add nsw i32 [[ADD]], [[L2]]
+; CHECK-NEXT: [[ADD9:%.*]] = add nsw i32 [[ADD8]], [[L3]]
+; CHECK-NEXT: ret i32 [[ADD9]]
+;
+check.0.min:
+ %c.min.0 = icmp ult i32* %src, %min
+ br i1 %c.min.0, label %trap, label %check.0.max
+
+trap: ; preds = %check.2.max, %check.2.min, %check.1.max, %check.1.min, %check.3.max, %check.3.min, %check.0.max, %check.0.min
+ ret i32 10
+
+check.0.max: ; preds = %check.0.min
+ %c.max.0 = icmp ult i32* %src, %max
+ br i1 %c.max.0, label %check.3.min, label %trap
+
+check.3.min: ; preds = %check.0.max
+ %l0 = load i32, i32* %src, align 4
+ %add.ptr.i36 = getelementptr inbounds i32, i32* %src, i64 3
+ %c.3.min = icmp ult i32* %add.ptr.i36, %min
+ br i1 %c.3.min, label %trap, label %check.3.max
+
+check.3.max: ; preds = %check.3.min
+ %c.3.max = icmp ult i32* %add.ptr.i36, %max
+ br i1 %c.3.max, label %check.1.min, label %trap
+
+check.1.min: ; preds = %check.3.max
+ %l1 = load i32, i32* %add.ptr.i36, align 4
+ %add.ptr.i29 = getelementptr inbounds i32, i32* %src, i64 1
+ %c.1.min = icmp ult i32* %add.ptr.i29, %min
+ br i1 %c.1.min, label %trap, label %check.1.max
+
+check.1.max: ; preds = %check.1.min
+ %c.1.max = icmp ult i32* %add.ptr.i29, %max
+ br i1 %c.1.max, label %check.2.min, label %trap
+
+check.2.min: ; preds = %check.1.max
+ %l2 = load i32, i32* %add.ptr.i29, align 4
+ %add.ptr.i = getelementptr inbounds i32, i32* %src, i64 2
+ %c.2.min = icmp ult i32* %add.ptr.i, %min
+ br i1 %c.2.min, label %trap, label %check.2.max
+
+check.2.max: ; preds = %check.2.min
+ %c.2.max = icmp ult i32* %add.ptr.i, %max
+ br i1 %c.2.max, label %exit, label %trap
+
+exit: ; preds = %check.2.max
+ %l3 = load i32, i32* %add.ptr.i, align 4
+ %add = add nsw i32 %l1, %l0
+ %add8 = add nsw i32 %add, %l2
+ %add9 = add nsw i32 %add8, %l3
+ ret i32 %add9
+}
+
+define void @test.not.uge.ult(i8* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.ult(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i8, i8* [[START:%.*]], i64 3
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[T_0:%.*]] = icmp ult i8* [[START]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_0]])
+; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 1
+; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8* [[START_1]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[START_2:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 2
+; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8* [[START_2]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: [[START_3:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 3
+; CHECK-NEXT: [[T_3:%.*]] = icmp ult i8* [[START_3]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_3]])
+; CHECK-NEXT: [[START_4:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 4
+; CHECK-NEXT: [[C_4:%.*]] = icmp ult i8* [[START_4]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds i8, i8* %start, i64 3
+ %c.1 = icmp uge i8* %add.ptr.i, %high
+ br i1 %c.1, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %t.0 = icmp ult i8* %start, %high
+ call void @use(i1 %t.0)
+ %start.1 = getelementptr inbounds i8, i8* %start, i64 1
+ %t.1 = icmp ult i8* %start.1, %high
+ call void @use(i1 %t.1)
+ %start.2 = getelementptr inbounds i8, i8* %start, i64 2
+ %t.2 = icmp ult i8* %start.2, %high
+ call void @use(i1 %t.2)
+ %start.3 = getelementptr inbounds i8, i8* %start, i64 3
+ %t.3 = icmp ult i8* %start.3, %high
+ call void @use(i1 %t.3)
+ %start.4 = getelementptr inbounds i8, i8* %start, i64 4
+ %c.4 = icmp ult i8* %start.4, %high
+ call void @use(i1 %c.4)
+ ret void
+}
+
+define void @test.not.uge.ule(i8* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.ule(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i8, i8* [[START:%.*]], i64 3
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[T_0:%.*]] = icmp ule i8* [[START]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_0]])
+; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 1
+; CHECK-NEXT: [[T_1:%.*]] = icmp ule i8* [[START_1]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[START_2:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 2
+; CHECK-NEXT: [[T_2:%.*]] = icmp ule i8* [[START_2]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: [[START_3:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 3
+; CHECK-NEXT: [[T_3:%.*]] = icmp ule i8* [[START_3]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_3]])
+; CHECK-NEXT: [[START_4:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 4
+; CHECK-NEXT: [[T_4:%.*]] = icmp ule i8* [[START_4]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[T_4]])
+; CHECK-NEXT: [[START_5:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 5
+; CHECK-NEXT: [[C_5:%.*]] = icmp ule i8* [[START_5]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds i8, i8* %start, i64 3
+ %c.1 = icmp uge i8* %add.ptr.i, %high
+ br i1 %c.1, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %t.0 = icmp ule i8* %start, %high
+ call void @use(i1 %t.0)
+ %start.1 = getelementptr inbounds i8, i8* %start, i64 1
+ %t.1 = icmp ule i8* %start.1, %high
+ call void @use(i1 %t.1)
+ %start.2 = getelementptr inbounds i8, i8* %start, i64 2
+ %t.2 = icmp ule i8* %start.2, %high
+ call void @use(i1 %t.2)
+ %start.3 = getelementptr inbounds i8, i8* %start, i64 3
+ %t.3 = icmp ule i8* %start.3, %high
+ call void @use(i1 %t.3)
+ %start.4 = getelementptr inbounds i8, i8* %start, i64 4
+ %t.4 = icmp ule i8* %start.4, %high
+ call void @use(i1 %t.4)
+
+ %start.5 = getelementptr inbounds i8, i8* %start, i64 5
+ %c.5 = icmp ule i8* %start.5, %high
+ call void @use(i1 %c.5)
+
+ ret void
+}
+
+define void @test.not.uge.ugt(i8* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.ugt(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i8, i8* [[START:%.*]], i64 3
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[F_0:%.*]] = icmp ugt i8* [[START]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_0]])
+; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 1
+; CHECK-NEXT: [[F_1:%.*]] = icmp ugt i8* [[START_1]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: [[START_2:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 2
+; CHECK-NEXT: [[F_2:%.*]] = icmp ugt i8* [[START_2]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_2]])
+; CHECK-NEXT: [[START_3:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 3
+; CHECK-NEXT: [[F_3:%.*]] = icmp ugt i8* [[START_3]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_3]])
+; CHECK-NEXT: [[START_4:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 4
+; CHECK-NEXT: [[F_4:%.*]] = icmp ugt i8* [[START_4]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_4]])
+; CHECK-NEXT: [[START_5:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 5
+; CHECK-NEXT: [[C_5:%.*]] = icmp ugt i8* [[START_5]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds i8, i8* %start, i64 3
+ %c.1 = icmp uge i8* %add.ptr.i, %high
+ br i1 %c.1, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %f.0 = icmp ugt i8* %start, %high
+ call void @use(i1 %f.0)
+
+ %start.1 = getelementptr inbounds i8, i8* %start, i64 1
+ %f.1 = icmp ugt i8* %start.1, %high
+ call void @use(i1 %f.1)
+
+ %start.2 = getelementptr inbounds i8, i8* %start, i64 2
+ %f.2 = icmp ugt i8* %start.2, %high
+ call void @use(i1 %f.2)
+
+ %start.3 = getelementptr inbounds i8, i8* %start, i64 3
+ %f.3 = icmp ugt i8* %start.3, %high
+ call void @use(i1 %f.3)
+
+ %start.4 = getelementptr inbounds i8, i8* %start, i64 4
+ %f.4 = icmp ugt i8* %start.4, %high
+ call void @use(i1 %f.4)
+
+ %start.5 = getelementptr inbounds i8, i8* %start, i64 5
+ %c.5 = icmp ugt i8* %start.5, %high
+ call void @use(i1 %c.5)
+
+ ret void
+}
+
+define void @test.not.uge.uge(i8* %start, i8* %low, i8* %high) {
+; CHECK-LABEL: @test.not.uge.uge(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i8, i8* [[START:%.*]], i64 3
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: ret void
+; CHECK: if.end:
+; CHECK-NEXT: [[F_0:%.*]] = icmp ugt i8* [[START]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_0]])
+; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 1
+; CHECK-NEXT: [[F_1:%.*]] = icmp uge i8* [[START_1]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: [[START_2:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 2
+; CHECK-NEXT: [[F_2:%.*]] = icmp uge i8* [[START_2]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_2]])
+; CHECK-NEXT: [[START_3:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 3
+; CHECK-NEXT: [[F_3:%.*]] = icmp uge i8* [[START_3]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[F_3]])
+; CHECK-NEXT: [[START_4:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 4
+; CHECK-NEXT: [[C_4:%.*]] = icmp uge i8* [[START_4]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: [[START_5:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 5
+; CHECK-NEXT: [[C_5:%.*]] = icmp uge i8* [[START_5]], [[HIGH]]
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %add.ptr.i = getelementptr inbounds i8, i8* %start, i64 3
+ %c.1 = icmp uge i8* %add.ptr.i, %high
+ br i1 %c.1, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ %f.0 = icmp ugt i8* %start, %high
+ call void @use(i1 %f.0)
+
+ %start.1 = getelementptr inbounds i8, i8* %start, i64 1
+ %f.1 = icmp uge i8* %start.1, %high
+ call void @use(i1 %f.1)
+
+ %start.2 = getelementptr inbounds i8, i8* %start, i64 2
+ %f.2 = icmp uge i8* %start.2, %high
+ call void @use(i1 %f.2)
+
+ %start.3 = getelementptr inbounds i8, i8* %start, i64 3
+ %f.3 = icmp uge i8* %start.3, %high
+ call void @use(i1 %f.3)
+
+ %start.4 = getelementptr inbounds i8, i8* %start, i64 4
+ %c.4 = icmp uge i8* %start.4, %high
+ call void @use(i1 %c.4)
+
+ %start.5 = getelementptr inbounds i8, i8* %start, i64 5
+ %c.5 = icmp uge i8* %start.5, %high
+ call void @use(i1 %c.5)
+
+ ret void
+}
+
+
+declare void @use(i1)
+declare void @llvm.trap()
diff --git a/llvm/test/Transforms/ConstraintElimination/i128.ll b/llvm/test/Transforms/ConstraintElimination/i128.ll
new file mode 100644
index 0000000000000..6a10ea770dd58
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/i128.ll
@@ -0,0 +1,37 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+declare void @use(i1)
+
+define void @test_unsigned_too_large(i128 %x) {
+; CHECK-LABEL: @test_unsigned_too_large(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i128 [[X:%.*]], 12345678901234123123123
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ult i128 [[X]], -12345678901234123123123
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: [[C_3:%.*]] = icmp uge i128 [[X]], -12345678901234123123123
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: [[C_4:%.*]] = icmp uge i128 [[X]], -12345678901234123123123
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: ret void
+; CHECK: bb2:
+; CHECK-NEXT: ret void
+;
+entry:
+ %c.1 = icmp ule i128 %x, 12345678901234123123123
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %c.2 = icmp ult i128 %x, -12345678901234123123123
+ call void @use(i1 %c.2)
+ %c.3 = icmp uge i128 %x, -12345678901234123123123
+ call void @use(i1 %c.3)
+ %c.4 = icmp uge i128 %x, -12345678901234123123123
+ call void @use(i1 %c.4)
+ ret void
+
+bb2:
+ ret void
+}
diff --git a/llvm/test/Transforms/ConstraintElimination/loops.ll b/llvm/test/Transforms/ConstraintElimination/loops.ll
new file mode 100644
index 0000000000000..be25308c46dfe
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/loops.ll
@@ -0,0 +1,47 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+; Make sure conditions in loops are not used to simplify themselves.
+
+define void @loop1(float* %T, float* %x, i32 %points, i32 %trigint) {
+; CHECK-LABEL: @loop1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[POINTS:%.*]] to i64
+; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds float, float* [[X:%.*]], i64 [[IDX_EXT]]
+; CHECK-NEXT: [[ADD_PTR1:%.*]] = getelementptr inbounds float, float* [[ADD_PTR]], i64 -8
+; CHECK-NEXT: [[SHR:%.*]] = ashr i32 [[POINTS]], 1
+; CHECK-NEXT: [[IDX_EXT2:%.*]] = sext i32 [[SHR]] to i64
+; CHECK-NEXT: [[ADD_PTR3:%.*]] = getelementptr inbounds float, float* [[X]], i64 [[IDX_EXT2]]
+; CHECK-NEXT: [[ADD_PTR4:%.*]] = getelementptr inbounds float, float* [[ADD_PTR3]], i64 -8
+; CHECK-NEXT: br label [[DO_BODY:%.*]]
+; CHECK: do.body:
+; CHECK-NEXT: [[X2_0:%.*]] = phi float* [ [[ADD_PTR4]], [[ENTRY:%.*]] ], [ [[ADD_PTR106:%.*]], [[DO_BODY]] ]
+; CHECK-NEXT: [[X1_0:%.*]] = phi float* [ [[ADD_PTR1]], [[ENTRY]] ], [ [[ADD_PTR105:%.*]], [[DO_BODY]] ]
+; CHECK-NEXT: [[ADD_PTR105]] = getelementptr inbounds float, float* [[X1_0]], i64 -8
+; CHECK-NEXT: [[ADD_PTR106]] = getelementptr inbounds float, float* [[X2_0]], i64 -8
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge float* [[ADD_PTR106]], [[X]]
+; CHECK-NEXT: br i1 [[CMP]], label [[DO_BODY]], label [[DO_END:%.*]]
+; CHECK: do.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ %idx.ext = sext i32 %points to i64
+ %add.ptr = getelementptr inbounds float, float* %x, i64 %idx.ext
+ %add.ptr1 = getelementptr inbounds float, float* %add.ptr, i64 -8
+ %shr = ashr i32 %points, 1
+ %idx.ext2 = sext i32 %shr to i64
+ %add.ptr3 = getelementptr inbounds float, float* %x, i64 %idx.ext2
+ %add.ptr4 = getelementptr inbounds float, float* %add.ptr3, i64 -8
+ br label %do.body
+
+do.body: ; preds = %do.body, %entry
+ %x2.0 = phi float* [ %add.ptr4, %entry ], [ %add.ptr106, %do.body ]
+ %x1.0 = phi float* [ %add.ptr1, %entry ], [ %add.ptr105, %do.body ]
+ %add.ptr105 = getelementptr inbounds float, float* %x1.0, i64 -8
+ %add.ptr106 = getelementptr inbounds float, float* %x2.0, i64 -8
+ %cmp = icmp uge float* %add.ptr106, %x
+ br i1 %cmp, label %do.body, label %do.end
+
+do.end: ; preds = %do.body
+ ret void
+}
diff --git a/llvm/test/Transforms/ConstraintElimination/mixed.ll b/llvm/test/Transforms/ConstraintElimination/mixed.ll
new file mode 100644
index 0000000000000..e4a264a8f0a0f
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/mixed.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+; Make sure we do not incorrectly add variables to the system.
+
+define i1 @test(i32* %p1, i32* %p2, i32 %num_rows, i32 %start_row, i1 %c) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[NUM_ROWS:%.*]], [[START_ROW:%.*]]
+; CHECK-NEXT: [[L3:%.*]] = load i32, i32* [[P1:%.*]], align 4
+; CHECK-NEXT: [[CMP6:%.*]] = icmp ugt i32 [[L3]], [[START_ROW]]
+; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_END36:%.*]], label [[IF_END36]]
+; CHECK: if.end36:
+; CHECK-NEXT: [[L1:%.*]] = load i32, i32* [[P2:%.*]], align 4
+; CHECK-NEXT: [[CMP37:%.*]] = icmp ult i32 [[L1]], [[ADD]]
+; CHECK-NEXT: br i1 [[CMP37]], label [[IF_THEN39:%.*]], label [[EXIT:%.*]]
+; CHECK: if.then39:
+; CHECK-NEXT: [[CMP41:%.*]] = icmp ult i32 [[L1]], [[START_ROW]]
+; CHECK-NEXT: ret i1 [[CMP41]]
+; CHECK: exit:
+; CHECK-NEXT: ret i1 false
+;
+entry:
+ %add = add i32 %num_rows, %start_row
+ %l3 = load i32, i32* %p1, align 4
+ %cmp6 = icmp ugt i32 %l3, %start_row
+ br i1 %c, label %if.end36, label %if.end36
+
+if.end36: ; preds = %if.then11
+ %l1 = load i32, i32* %p2, align 4
+ %cmp37 = icmp ult i32 %l1, %add
+ br i1 %cmp37, label %if.then39, label %exit
+
+if.then39: ; preds = %if.end36
+ %cmp41 = icmp ult i32 %l1, %start_row
+ ret i1 %cmp41
+
+exit: ; preds = %if.end36
+ ret i1 false
+}
diff --git a/llvm/test/Transforms/ConstraintElimination/uge.ll b/llvm/test/Transforms/ConstraintElimination/uge.ll
new file mode 100644
index 0000000000000..ca91733d2af98
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/uge.ll
@@ -0,0 +1,255 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+declare void @use(i1)
+
+define void @test_1_variable_constraint(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: @test_1_variable_constraint(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[T_1:%.*]] = icmp uge i32 [[X]], [[Y]]
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: [[C_3:%.*]] = icmp uge i32 [[Y]], [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: [[C_4:%.*]] = icmp uge i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: ret void
+; CHECK: bb2:
+; CHECK-NEXT: [[T_2:%.*]] = icmp uge i32 [[Y]], [[X]]
+; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: [[F_1:%.*]] = icmp uge i32 [[X]], [[Y]]
+; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: [[C_5:%.*]] = icmp uge i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: [[C_6:%.*]] = icmp uge i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_6]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %c.1 = icmp uge i32 %x, %y
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %t.1 = icmp uge i32 %x, %y
+ call void @use(i1 %t.1)
+ %c.2 = icmp uge i32 %x, 10
+ call void @use(i1 %c.2)
+ %c.3 = icmp uge i32 %y, %x
+ call void @use(i1 %c.3)
+ %c.4 = icmp uge i32 10, %x
+ call void @use(i1 %c.4)
+ ret void
+
+bb2:
+ %t.2 = icmp uge i32 %y, %x
+ call void @use(i1 %t.2)
+ %f.1 = icmp uge i32 %x, %y
+ call void @use(i1 %f.1)
+ %c.5 = icmp uge i32 %x, 10
+ call void @use(i1 %c.5)
+ %c.6 = icmp uge i32 10, %x
+ call void @use(i1 %c.6)
+ ret void
+}
+
+define void @test_1_constant_constraint(i32 %x) {
+; CHECK-LABEL: @test_1_constant_constraint(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[T_1:%.*]] = icmp uge i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[T_2:%.*]] = icmp uge i32 [[X]], 9
+; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i32 [[X]], 11
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: [[C_4:%.*]] = icmp uge i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: ret void
+; CHECK: bb2:
+; CHECK-NEXT: [[T_3:%.*]] = icmp uge i32 11, [[X]]
+; CHECK-NEXT: call void @use(i1 [[T_3]])
+; CHECK-NEXT: [[F_1:%.*]] = icmp uge i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: [[F_1_1:%.*]] = icmp uge i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[F_1_1]])
+; CHECK-NEXT: [[C_5:%.*]] = icmp uge i32 [[X]], 9
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: [[C_6:%.*]] = icmp uge i32 1, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_6]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %c.1 = icmp uge i32 %x, 10
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %t.1 = icmp uge i32 %x, 10
+ call void @use(i1 %t.1)
+ %t.2 = icmp uge i32 %x, 9
+ call void @use(i1 %t.2)
+ %c.2 = icmp uge i32 %x, 11
+ call void @use(i1 %c.2)
+ %c.4 = icmp uge i32 10, %x
+ call void @use(i1 %c.4)
+ ret void
+
+bb2:
+ %t.3 = icmp uge i32 11, %x
+ call void @use(i1 %t.3)
+ %f.1 = icmp uge i32 %x, 10
+ call void @use(i1 %f.1)
+
+
+ %f.1.1 = icmp uge i32 %x, 10
+ call void @use(i1 %f.1.1)
+ %c.5 = icmp uge i32 %x, 9
+ call void @use(i1 %c.5)
+ %c.6 = icmp uge i32 1, %x
+ call void @use(i1 %c.6)
+ ret void
+}
+
+define i32 @test1(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i32 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp uge i32 [[X]], [[Z]]
+; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
+; CHECK: bb3:
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp uge i32 %x, %y
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp uge i32 %y, %z
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ %c.3 = icmp uge i32 %x, %z
+ br i1 %c.3, label %bb3, label %exit
+
+bb3:
+ ret i32 10
+
+exit:
+ ret i32 20
+}
+
+
+define i32 @test2(i32 %x, i32 %y, i32 %z, i32 %a) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i32 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp uge i32 [[X]], [[A:%.*]]
+; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
+; CHECK: bb3:
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp uge i32 %x, %y
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp uge i32 %y, %z
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ %c.3 = icmp uge i32 %x, %a
+ br i1 %c.3, label %bb3, label %exit
+
+bb3:
+ ret i32 10
+
+exit:
+ ret i32 20
+}
+
+
+define i32 @test3(i32 %x, i32 %y) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i32 [[Y:%.*]], 20
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp uge i32 %x, 10
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp uge i32 %y, 20
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ ret i32 10
+
+exit:
+ ret i32 20
+}
+
+define i32 @test4(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i32 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: [[T_1:%.*]] = icmp uge i32 [[X]], [[Z]]
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[U_1:%.*]] = icmp eq i32 [[X]], [[Z]]
+; CHECK-NEXT: call void @use(i1 [[U_1]])
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp uge i32 %x, %y
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp uge i32 %y, %z
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ %t.1 = icmp uge i32 %x, %z
+ call void @use(i1 %t.1)
+ %u.1 = icmp eq i32 %x, %z
+ call void @use(i1 %u.1)
+ ret i32 10
+
+
+exit:
+ ret i32 20
+}
+
+
diff --git a/llvm/test/Transforms/ConstraintElimination/ugt-ule.ll b/llvm/test/Transforms/ConstraintElimination/ugt-ule.ll
new file mode 100644
index 0000000000000..c49ce7360cd68
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/ugt-ule.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+declare void @use(i1)
+
+define void @test(i8* %m, i8* %ptr) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP_1:%.*]] = icmp ult i8* [[M:%.*]], [[PTR:%.*]]
+; CHECK-NEXT: br i1 [[CMP_1]], label [[BB_1:%.*]], label [[BB_2:%.*]]
+; CHECK: bb.1:
+; CHECK-NEXT: [[CMP_2:%.*]] = icmp uge i8* [[M]], [[PTR]]
+; CHECK-NEXT: call void @use(i1 [[CMP_2]])
+; CHECK-NEXT: ret void
+; CHECK: bb.2:
+; CHECK-NEXT: br label [[BB_2_NEXT:%.*]]
+; CHECK: bb.2.next:
+; CHECK-NEXT: [[CMP_3:%.*]] = icmp uge i8* [[M]], [[PTR]]
+; CHECK-NEXT: call void @use(i1 [[CMP_3]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %cmp.1 = icmp ult i8* %m, %ptr
+ br i1 %cmp.1, label %bb.1, label %bb.2
+
+bb.1:
+ %cmp.2 = icmp uge i8* %m, %ptr
+ call void @use(i1 %cmp.2)
+ ret void
+
+bb.2:
+ br label %bb.2.next
+
+bb.2.next:
+ %cmp.3 = icmp uge i8* %m, %ptr
+ call void @use(i1 %cmp.3)
+ ret void
+}
diff --git a/llvm/test/Transforms/ConstraintElimination/ule.ll b/llvm/test/Transforms/ConstraintElimination/ule.ll
new file mode 100644
index 0000000000000..2cb3750fad243
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/ule.ll
@@ -0,0 +1,254 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S %s | FileCheck %s
+
+declare void @use(i1)
+
+define void @test_1_variable_constraint(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: @test_1_variable_constraint(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], [[Y]]
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[Y]], [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_3]])
+; CHECK-NEXT: [[C_4:%.*]] = icmp ule i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: ret void
+; CHECK: bb2:
+; CHECK-NEXT: [[T_2:%.*]] = icmp ule i32 [[Y]], [[X]]
+; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: [[F_1:%.*]] = icmp ule i32 [[X]], [[Y]]
+; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: [[C_6:%.*]] = icmp ule i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_6]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %c.1 = icmp ule i32 %x, %y
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %t.1 = icmp ule i32 %x, %y
+ call void @use(i1 %t.1)
+ %c.2 = icmp ule i32 %x, 10
+ call void @use(i1 %c.2)
+ %c.3 = icmp ule i32 %y, %x
+ call void @use(i1 %c.3)
+ %c.4 = icmp ule i32 10, %x
+ call void @use(i1 %c.4)
+ ret void
+
+bb2:
+ %t.2 = icmp ule i32 %y, %x
+ call void @use(i1 %t.2)
+ %f.1 = icmp ule i32 %x, %y
+ call void @use(i1 %f.1)
+ %c.5 = icmp ule i32 %x, 10
+ call void @use(i1 %c.5)
+ %c.6 = icmp ule i32 10, %x
+ call void @use(i1 %c.6)
+ ret void
+}
+
+define void @test_1_constant_constraint(i32 %x) {
+; CHECK-LABEL: @test_1_constant_constraint(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[T_2:%.*]] = icmp ule i32 [[X]], 11
+; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 9
+; CHECK-NEXT: call void @use(i1 [[C_2]])
+; CHECK-NEXT: [[C_4:%.*]] = icmp ule i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_4]])
+; CHECK-NEXT: ret void
+; CHECK: bb2:
+; CHECK-NEXT: [[T_3:%.*]] = icmp ule i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[T_3]])
+; CHECK-NEXT: [[F_1:%.*]] = icmp ule i32 [[X]], 9
+; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: [[F_1_1:%.*]] = icmp ule i32 [[X]], 10
+; CHECK-NEXT: call void @use(i1 [[F_1_1]])
+; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], 11
+; CHECK-NEXT: call void @use(i1 [[C_5]])
+; CHECK-NEXT: [[C_6:%.*]] = icmp ule i32 10, [[X]]
+; CHECK-NEXT: call void @use(i1 [[C_6]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %c.1 = icmp ule i32 %x, 10
+ br i1 %c.1, label %bb1, label %bb2
+
+bb1:
+ %t.1 = icmp ule i32 %x, 10
+ call void @use(i1 %t.1)
+ %t.2 = icmp ule i32 %x, 11
+ call void @use(i1 %t.2)
+ %c.2 = icmp ule i32 %x, 9
+ call void @use(i1 %c.2)
+ %c.4 = icmp ule i32 10, %x
+ call void @use(i1 %c.4)
+ ret void
+
+bb2:
+ %t.3 = icmp ule i32 10, %x
+ call void @use(i1 %t.3)
+ %f.1 = icmp ule i32 %x, 9
+ call void @use(i1 %f.1)
+
+
+ %f.1.1 = icmp ule i32 %x, 10
+ call void @use(i1 %f.1.1)
+ %c.5 = icmp ule i32 %x, 11
+ call void @use(i1 %c.5)
+ %c.6 = icmp ule i32 10, %x
+ call void @use(i1 %c.6)
+ ret void
+}
+
+
+define i32 @test1(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], [[Z]]
+; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
+; CHECK: bb3:
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp ule i32 %x, %y
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp ule i32 %y, %z
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ %c.3 = icmp ule i32 %x, %z
+ br i1 %c.3, label %bb3, label %exit
+
+bb3:
+ ret i32 10
+
+exit:
+ ret i32 20
+}
+
+
+define i32 @test2(i32 %x, i32 %y, i32 %z, i32 %a) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], [[A:%.*]]
+; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
+; CHECK: bb3:
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp ule i32 %x, %y
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp ule i32 %y, %z
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ %c.3 = icmp ule i32 %x, %a
+ br i1 %c.3, label %bb3, label %exit
+
+bb3:
+ ret i32 10
+
+exit:
+ ret i32 20
+}
+
+
+define i32 @test3(i32 %x, i32 %y) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y:%.*]], 20
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp ule i32 %x, 10
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp ule i32 %y, 20
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ ret i32 10
+
+exit:
+ ret i32 20
+}
+
+define i32 @test4(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
+; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
+; CHECK: bb2:
+; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], [[Z]]
+; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: [[U_1:%.*]] = icmp eq i32 [[X]], [[Z]]
+; CHECK-NEXT: call void @use(i1 [[U_1]])
+; CHECK-NEXT: ret i32 10
+; CHECK: exit:
+; CHECK-NEXT: ret i32 20
+;
+entry:
+ %c.1 = icmp ule i32 %x, %y
+ br i1 %c.1, label %bb1, label %exit
+
+bb1:
+ %c.2 = icmp ule i32 %y, %z
+ br i1 %c.2, label %bb2, label %exit
+
+bb2:
+ %t.1 = icmp ule i32 %x, %z
+ call void @use(i1 %t.1)
+ %u.1 = icmp eq i32 %x, %z
+ call void @use(i1 %u.1)
+ ret i32 10
+
+
+exit:
+ ret i32 20
+}
More information about the llvm-commits
mailing list