[llvm] 2229674 - [ConstraintElimination] Add additional tests with uncond branches.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 16 02:46:09 PDT 2022
Author: Florian Hahn
Date: 2022-03-16T09:46:04Z
New Revision: 2229674cb7163c01e05dc58ab90084b4fb80c78a
URL: https://github.com/llvm/llvm-project/commit/2229674cb7163c01e05dc58ab90084b4fb80c78a
DIFF: https://github.com/llvm/llvm-project/commit/2229674cb7163c01e05dc58ab90084b4fb80c78a.diff
LOG: [ConstraintElimination] Add additional tests with uncond branches.
Added:
Modified:
llvm/test/Transforms/ConstraintElimination/assumes.ll
llvm/test/Transforms/ConstraintElimination/dom.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/ConstraintElimination/assumes.ll b/llvm/test/Transforms/ConstraintElimination/assumes.ll
index d51098e6c4df3..c27835a7a36db 100644
--- a/llvm/test/Transforms/ConstraintElimination/assumes.ll
+++ b/llvm/test/Transforms/ConstraintElimination/assumes.ll
@@ -180,6 +180,28 @@ exit:
ret i1 %c.2
}
+define i1 @assume_dominates_successor_with_may_unwind_call_before_assume_uncond_branch(i16 %a) {
+; CHECK-LABEL: @assume_dominates_successor_with_may_unwind_call_before_assume_uncond_branch(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: call void @may_unwind()
+; CHECK-NEXT: [[C_1:%.*]] = icmp eq i16 [[A:%.*]], 0
+; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: [[C_2:%.*]] = icmp eq i16 [[A]], 0
+; CHECK-NEXT: ret i1 [[C_2]]
+;
+entry:
+ call void @may_unwind()
+ %c.1 = icmp eq i16 %a, 0
+ call void @llvm.assume(i1 %c.1)
+ br label %exit
+
+exit:
+ %c.2 = icmp eq i16 %a, 0
+ ret i1 %c.2
+}
+
define i1 @assume_single_bb(i8 %a, i8 %b, i1 %c) {
; CHECK-LABEL: @assume_single_bb(
; CHECK-NEXT: [[ADD_1:%.*]] = add nuw nsw i8 [[A:%.*]], 1
@@ -517,4 +539,3 @@ define i1 @all_uses_after_assume(i8 %a, i8 %b, i1 %c) {
%res.2 = xor i1 %res.1, %c.2
ret i1 %res.2
}
-
diff --git a/llvm/test/Transforms/ConstraintElimination/dom.ll b/llvm/test/Transforms/ConstraintElimination/dom.ll
index 9cf84ca4efede..80d843eaf8ed8 100644
--- a/llvm/test/Transforms/ConstraintElimination/dom.ll
+++ b/llvm/test/Transforms/ConstraintElimination/dom.ll
@@ -33,6 +33,69 @@ bb2:
ret i1 %c.3
}
+define i1 @test_chain_1(i8 %x) {
+; CHECK-LABEL: @test_chain_1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i8 [[X]], 10
+; CHECK-NEXT: call void @use(i1 true)
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i8 [[X]], 10
+; CHECK-NEXT: ret i1 [[C_3]]
+;
+entry:
+ %c.1 = icmp ule i8 %x, 10
+ br i1 %c.1, label %then, label %else
+
+then:
+ %c.2 = icmp ule i8 %x, 10
+ call void @use(i1 %c.2)
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %c.3 = icmp ugt i8 %x, 10
+ ret i1 %c.3
+}
+
+define i1 @test_chain_2(i8 %x) {
+; CHECK-LABEL: @test_chain_2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8 [[X:%.*]], 10
+; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: [[C_2:%.*]] = icmp ule i8 [[X]], 10
+; CHECK-NEXT: call void @use(i1 false)
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i8 [[X]], 10
+; CHECK-NEXT: ret i1 [[C_3]]
+;
+entry:
+ %c.1 = icmp ule i8 %x, 10
+ br i1 %c.1, label %then, label %else
+
+then:
+ br label %exit
+
+else:
+ %c.2 = icmp ule i8 %x, 10
+ call void @use(i1 %c.2)
+ br label %exit
+
+exit:
+ %c.3 = icmp ugt i8 %x, 10
+ ret i1 %c.3
+}
define i1 @test2(i8 %x) {
; CHECK-LABEL: @test2(
@@ -61,7 +124,6 @@ bb2:
br label %bb1
}
-
; Test cases where the true/false successors are not domianted by the conditional branching block.
define i1 @test3(i8 %x, i1 %c) {
; CHECK-LABEL: @test3(
More information about the llvm-commits
mailing list