[PATCH] D124603: [SimpleLoopUnswitch] Add freeze if branch execs for partial unswitching.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 01:44:52 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6bd2b7087761: [SimpleLoopUnswitch] Add freeze if branch execs for partial unswitching. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124603/new/

https://reviews.llvm.org/D124603

Files:
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll


Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll
===================================================================
--- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll
@@ -2717,7 +2717,8 @@
 entry:
   br label %loop_begin
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 %cond, label %entry.split.us, label %entry.split
+; CHECK-NEXT:    [[FROZEN:%.+]] = freeze i1 %cond
+; CHECK-NEXT:    br i1 [[FROZEN]], label %entry.split.us, label %entry.split
 
 loop_begin:
   %v1 = load i1, i1* %ptr
@@ -2790,7 +2791,9 @@
 entry:
   br label %loop_begin
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    %[[INV_AND:.*]] = and i1 %cond3, %cond1
+; CHECK-NEXT:    [[C3_FR:%.+]] = freeze i1 %cond3
+; CHECK-NEXT:    [[C1_FR:%.+]] = freeze i1 %cond1
+; CHECK-NEXT:    %[[INV_AND:.*]] = and i1 [[C3_FR]], [[C1_FR]]
 ; CHECK-NEXT:    br i1 %[[INV_AND]], label %entry.split, label %entry.split.us
 
 loop_begin:
@@ -2871,7 +2874,9 @@
 entry:
   br label %loop_begin
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    %[[INV_OR:.*]] = or i1 %cond3, %cond1
+; CHECK-NEXT:    [[C3_FR:%.+]] = freeze i1 %cond3
+; CHECK-NEXT:    [[C1_FR:%.+]] = freeze i1 %cond1
+; CHECK-NEXT:    %[[INV_OR:.*]] = or i1 [[C3_FR]], [[C1_FR]]
 ; CHECK-NEXT:    br i1 %[[INV_OR]], label %entry.split.us, label %entry.split
 
 loop_begin:
@@ -4231,7 +4236,9 @@
 entry:
   br label %loop_begin
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    %[[INV_AND:.*]] = and i1 %cond2, %cond1
+; CHECK-NEXT:    [[C2_FR:%.+]] = freeze i1 %cond2
+; CHECK-NEXT:    [[C1_FR:%.+]] = freeze i1 %cond1
+; CHECK-NEXT:    %[[INV_AND:.*]] = and i1 [[C2_FR]], [[C1_FR]]
 ; CHECK-NEXT:    br i1 %[[INV_AND]], label %entry.split, label %entry.split.us
 
 loop_begin:
@@ -4309,7 +4316,9 @@
 entry:
   br label %loop_begin
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    %[[INV_OR:.*]] = or i1 %cond2, %cond1
+; CHECK-NEXT:    [[C2_FR:%.+]] = freeze i1 %cond2
+; CHECK-NEXT:    [[C1_FR:%.+]] = freeze i1 %cond1
+; CHECK-NEXT:    %[[INV_OR:.*]] = or i1 [[C2_FR]], [[C1_FR]]
 ; CHECK-NEXT:    br i1 %[[INV_OR]], label %entry.split.us, label %entry.split
 
 loop_begin:
Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -2321,9 +2321,9 @@
       buildPartialInvariantUnswitchConditionalBranch(
           *SplitBB, Invariants, Direction, *ClonedPH, *LoopPH, L, MSSAU);
     else {
-      buildPartialUnswitchConditionalBranch(*SplitBB, Invariants, Direction,
-                                            *ClonedPH, *LoopPH, InsertFreeze,
-                                            BI, &AC, DT);
+      buildPartialUnswitchConditionalBranch(
+          *SplitBB, Invariants, Direction, *ClonedPH, *LoopPH,
+          FreezeLoopUnswitchCond, BI, &AC, DT);
     }
     DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH});
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124603.427240.patch
Type: text/x-patch
Size: 3018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220505/e4c350fd/attachment.bin>


More information about the llvm-commits mailing list