[llvm] 5ae4a17 - [InstCombine] Add tests for freeze of recurrence with invoke start (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 01:15:20 PDT 2022
Author: Nikita Popov
Date: 2022-06-17T10:15:12+02:00
New Revision: 5ae4a173ddc70cf1a84603cd774e67e00935ecc7
URL: https://github.com/llvm/llvm-project/commit/5ae4a173ddc70cf1a84603cd774e67e00935ecc7
DIFF: https://github.com/llvm/llvm-project/commit/5ae4a173ddc70cf1a84603cd774e67e00935ecc7.diff
LOG: [InstCombine] Add tests for freeze of recurrence with invoke start (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/freeze.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/freeze.ll b/llvm/test/Transforms/InstCombine/freeze.ll
index 4e48d4e384de2..24607037ac8a8 100644
--- a/llvm/test/Transforms/InstCombine/freeze.ll
+++ b/llvm/test/Transforms/InstCombine/freeze.ll
@@ -740,8 +740,8 @@ exit: ; preds = %loop
ret void
}
-define void @fold_phi_neg_flags(i32 %init, i32 %n) {
-; CHECK-LABEL: @fold_phi_neg_flags(
+define void @fold_phi_drop_flags(i32 %init, i32 %n) {
+; CHECK-LABEL: @fold_phi_drop_flags(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
@@ -917,6 +917,80 @@ exit:
ret void
}
+define void @fold_phi_invoke_start_value(i32 %n) personality i8* undef {
+; CHECK-LABEL: @fold_phi_invoke_start_value(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[INIT:%.*]] = invoke i32 @get_i32()
+; CHECK-NEXT: to label [[LOOP:%.*]] unwind label [[UNWIND:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[INIT]], [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[I_FR:%.*]] = freeze i32 [[I]]
+; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I_FR]], 1
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[I_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: unwind:
+; CHECK-NEXT: [[TMP0:%.*]] = landingpad i8
+; CHECK-NEXT: cleanup
+; CHECK-NEXT: unreachable
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ %init = invoke i32 @get_i32()
+ to label %loop unwind label %unwind
+
+loop:
+ %i = phi i32 [ %init, %entry ], [ %i.next, %loop ]
+ %i.fr = freeze i32 %i
+ %i.next = add nsw nuw i32 %i.fr, 1
+ %cond = icmp eq i32 %i.next, %n
+ br i1 %cond, label %loop, label %exit
+
+unwind:
+ landingpad i8 cleanup
+ unreachable
+
+exit:
+ ret void
+}
+
+define void @fold_phi_invoke_noundef_start_value(i32 %n) personality i8* undef {
+; CHECK-LABEL: @fold_phi_invoke_noundef_start_value(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[INIT:%.*]] = invoke noundef i32 @get_i32()
+; CHECK-NEXT: to label [[LOOP:%.*]] unwind label [[UNWIND:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[INIT]], [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: [[I_FR:%.*]] = freeze i32 [[I]]
+; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I_FR]], 1
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[I_NEXT]], [[N:%.*]]
+; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: unwind:
+; CHECK-NEXT: [[TMP0:%.*]] = landingpad i8
+; CHECK-NEXT: cleanup
+; CHECK-NEXT: unreachable
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ %init = invoke noundef i32 @get_i32()
+ to label %loop unwind label %unwind
+
+loop:
+ %i = phi i32 [ %init, %entry ], [ %i.next, %loop ]
+ %i.fr = freeze i32 %i
+ %i.next = add nsw nuw i32 %i.fr, 1
+ %cond = icmp eq i32 %i.next, %n
+ br i1 %cond, label %loop, label %exit
+
+unwind:
+ landingpad i8 cleanup
+ unreachable
+
+exit:
+ ret void
+}
+
define i8* @freeze_load_noundef(i8** %ptr) {
; CHECK-LABEL: @freeze_load_noundef(
; CHECK-NEXT: [[P:%.*]] = load i8*, i8** [[PTR:%.*]], align 8, !noundef !0
More information about the llvm-commits
mailing list