[llvm] 3c4d222 - [InstCombine] Add more tests for unreachable code (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 06:37:02 PDT 2023
Author: Nikita Popov
Date: 2023-07-27T15:36:54+02:00
New Revision: 3c4d2221de0e9e7b259a308aab7e72e3f2f926f1
URL: https://github.com/llvm/llvm-project/commit/3c4d2221de0e9e7b259a308aab7e72e3f2f926f1
DIFF: https://github.com/llvm/llvm-project/commit/3c4d2221de0e9e7b259a308aab7e72e3f2f926f1.diff
LOG: [InstCombine] Add more tests for unreachable code (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/unreachable-code.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/unreachable-code.ll b/llvm/test/Transforms/InstCombine/unreachable-code.ll
index 068ff72cde1c3f..eea4ff987d17bf 100644
--- a/llvm/test/Transforms/InstCombine/unreachable-code.ll
+++ b/llvm/test/Transforms/InstCombine/unreachable-code.ll
@@ -228,6 +228,32 @@ join:
ret i32 %phi
}
+define void @non_term_unreachable_following_blocks() {
+; CHECK-LABEL: define void @non_term_unreachable_following_blocks() {
+; CHECK-NEXT: call void @dummy()
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: br label [[SPLIT:%.*]]
+; CHECK: split:
+; CHECK-NEXT: call void @dummy()
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: call void @dummy()
+; CHECK-NEXT: br label [[LOOP]]
+;
+ call void @dummy()
+ store i1 true, ptr poison
+ call void @dummy()
+ br label %split
+
+split:
+ call void @dummy()
+ br label %loop
+
+loop:
+ call void @dummy()
+ br label %loop
+}
+
define void @br_not_into_loop(i1 %x) {
; CHECK-LABEL: define void @br_not_into_loop
; CHECK-SAME: (i1 [[X:%.*]]) {
@@ -271,6 +297,128 @@ exit:
call void @dummy()
ret void
}
-;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
-; DEFAULT_ITER: {{.*}}
-; MAX1: {{.*}}
+
+define void @two_br_not_into_loop(i1 %x) {
+; DEFAULT_ITER-LABEL: define void @two_br_not_into_loop
+; DEFAULT_ITER-SAME: (i1 [[X:%.*]]) {
+; DEFAULT_ITER-NEXT: br i1 true, label [[BB2:%.*]], label [[LOOP:%.*]]
+; DEFAULT_ITER: bb2:
+; DEFAULT_ITER-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
+; DEFAULT_ITER: loop:
+; DEFAULT_ITER-NEXT: br label [[LOOP]]
+; DEFAULT_ITER: exit:
+; DEFAULT_ITER-NEXT: call void @dummy()
+; DEFAULT_ITER-NEXT: ret void
+;
+; MAX1-LABEL: define void @two_br_not_into_loop
+; MAX1-SAME: (i1 [[X:%.*]]) {
+; MAX1-NEXT: br i1 true, label [[BB2:%.*]], label [[LOOP:%.*]]
+; MAX1: bb2:
+; MAX1-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]]
+; MAX1: loop:
+; MAX1-NEXT: call void @dummy()
+; MAX1-NEXT: br label [[LOOP]]
+; MAX1: exit:
+; MAX1-NEXT: call void @dummy()
+; MAX1-NEXT: ret void
+;
+ %c = or i1 %x, true
+ br i1 %c, label %bb2, label %loop
+
+bb2:
+ %c2 = or i1 %x, true
+ br i1 %c2, label %exit, label %loop
+
+loop:
+ call void @dummy()
+ br label %loop
+
+exit:
+ call void @dummy()
+ ret void
+}
+
+define void @one_br_into_loop_one_not(i1 %x, i1 %c2) {
+; CHECK-LABEL: define void @one_br_into_loop_one_not
+; CHECK-SAME: (i1 [[X:%.*]], i1 [[C2:%.*]]) {
+; CHECK-NEXT: br i1 true, label [[BB2:%.*]], label [[LOOP:%.*]]
+; CHECK: bb2:
+; CHECK-NEXT: br i1 [[C2]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: loop:
+; CHECK-NEXT: call void @dummy()
+; CHECK-NEXT: br label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: call void @dummy()
+; CHECK-NEXT: ret void
+;
+ %c = or i1 %x, true
+ br i1 %c, label %bb2, label %loop
+
+bb2:
+ br i1 %c2, label %exit, label %loop
+
+loop:
+ call void @dummy()
+ br label %loop
+
+exit:
+ call void @dummy()
+ ret void
+}
+
+define void @two_br_not_into_loop_with_split(i1 %x) {
+; DEFAULT_ITER-LABEL: define void @two_br_not_into_loop_with_split
+; DEFAULT_ITER-SAME: (i1 [[X:%.*]]) {
+; DEFAULT_ITER-NEXT: br i1 true, label [[BB2:%.*]], label [[SPLIT1:%.*]]
+; DEFAULT_ITER: bb2:
+; DEFAULT_ITER-NEXT: br i1 true, label [[EXIT:%.*]], label [[SPLIT2:%.*]]
+; DEFAULT_ITER: split1:
+; DEFAULT_ITER-NEXT: br label [[LOOP:%.*]]
+; DEFAULT_ITER: split2:
+; DEFAULT_ITER-NEXT: br label [[LOOP]]
+; DEFAULT_ITER: loop:
+; DEFAULT_ITER-NEXT: br label [[LOOP]]
+; DEFAULT_ITER: exit:
+; DEFAULT_ITER-NEXT: call void @dummy()
+; DEFAULT_ITER-NEXT: ret void
+;
+; MAX1-LABEL: define void @two_br_not_into_loop_with_split
+; MAX1-SAME: (i1 [[X:%.*]]) {
+; MAX1-NEXT: br i1 true, label [[BB2:%.*]], label [[SPLIT1:%.*]]
+; MAX1: bb2:
+; MAX1-NEXT: br i1 true, label [[EXIT:%.*]], label [[SPLIT2:%.*]]
+; MAX1: split1:
+; MAX1-NEXT: br label [[LOOP:%.*]]
+; MAX1: split2:
+; MAX1-NEXT: br label [[LOOP]]
+; MAX1: loop:
+; MAX1-NEXT: call void @dummy()
+; MAX1-NEXT: br label [[LOOP]]
+; MAX1: exit:
+; MAX1-NEXT: call void @dummy()
+; MAX1-NEXT: ret void
+;
+ %c = or i1 %x, true
+ br i1 %c, label %bb2, label %split1
+
+bb2:
+ %c2 = or i1 %x, true
+ br i1 %c2, label %exit, label %split2
+
+split1:
+ call void @dummy()
+ br label %loop
+
+split2:
+ call void @dummy()
+ br label %loop
+
+loop:
+ call void @dummy()
+ br label %loop
+
+exit:
+ call void @dummy()
+ ret void
+}
+
More information about the llvm-commits
mailing list