[ConstraintElimination] Add test case for PR54217.
authorFlorian Hahn <flo@fhahn.com>
Mon, 7 Mar 2022 12:01:09 +0000 (12:01 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 7 Mar 2022 12:01:10 +0000 (12:01 +0000)
Adds test case for https://github.com/llvm/llvm-project/issues/54217.

llvm/test/Transforms/ConstraintElimination/assumes.ll

index f916798..73a24dd 100644 (file)
@@ -152,6 +152,34 @@ else:
   ret i1 %res.4
 }
 
+; Test case from PR54217.
+define i1 @assume_does_not_dominates_successor_with_may_unwind_call_before_assume(i16 %a, i1 %i.0) {
+; CHECK-LABEL: @assume_does_not_dominates_successor_with_may_unwind_call_before_assume(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[I_0:%.*]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       if.then:
+; 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 true
+;
+entry:
+  br i1 %i.0, label %exit, label %if.then
+
+if.then:
+  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
@@ -489,3 +517,4 @@ define i1 @all_uses_after_assume(i8 %a, i8 %b, i1 %c) {
   %res.2 = xor i1 %res.1, %c.2
   ret i1 %res.2
 }
+