[PATCH] D148707: [FlattenCFG] Replace branch condition with a created one correctly
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 02:50:07 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8502c545771e: [FlattenCFG] Replace branch condition with a created one correctly (authored by mkazantsev).
Changed prior to commit:
https://reviews.llvm.org/D148707?vs=514907&id=515664#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148707/new/
https://reviews.llvm.org/D148707
Files:
llvm/lib/Transforms/Utils/FlattenCFG.cpp
llvm/test/Transforms/Util/flattencfg.ll
Index: llvm/test/Transforms/Util/flattencfg.ll
===================================================================
--- llvm/test/Transforms/Util/flattencfg.ll
+++ llvm/test/Transforms/Util/flattencfg.ll
@@ -269,8 +269,9 @@
}
; cmp.y has 2 users, but should be inverted. So that a new one cmp is created instead.
-; FIXME: Branch condition must be replaced with a new created combined condition
+; Branch condition must be replaced with a new created combined condition
; Proof of bug: https://alive2.llvm.org/ce/z/L4ps9v
+; Proof of fix: https://alive2.llvm.org/ce/z/QdrG5U
define i1 @test_cond_multi_use(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: define i1 @test_cond_multi_use
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
@@ -279,7 +280,7 @@
; CHECK-NEXT: [[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0
; CHECK-NEXT: [[TMP0:%.*]] = xor i1 [[CMP_Y]], true
; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[CMP_X]], [[TMP0]]
-; CHECK-NEXT: br i1 [[CMP_Y]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
+; CHECK-NEXT: br i1 [[TMP1]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
; CHECK: if.then.y:
; CHECK-NEXT: store i32 [[Z]], ptr @g, align 4
; CHECK-NEXT: br label [[EXIT]]
Index: llvm/lib/Transforms/Utils/FlattenCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/FlattenCFG.cpp
+++ llvm/lib/Transforms/Utils/FlattenCFG.cpp
@@ -497,7 +497,7 @@
PBI->swapSuccessors();
}
Value *NC = Builder.CreateBinOp(CombineOp, CInst1, CInst2);
- PBI->replaceUsesOfWith(CInst2, NC);
+ PBI->replaceUsesOfWith(PBI->getCondition(), NC);
Builder.SetInsertPoint(SaveInsertBB, SaveInsertPt);
// Handle PHI node to replace its predecessors to FirstEntryBlock.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148707.515664.patch
Type: text/x-patch
Size: 1748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230421/52e1d12c/attachment.bin>
More information about the llvm-commits
mailing list