Commit
https://alive2.llvm.org/ce/z/EfHlWN In the motivating case from issue #58313, this allows forming a duplicate 'not' op which then gets CSE'd and simplifyCFG'd and combined into the expected 'xor'.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3180,13 +3180,22 @@ Instruction *InstCombinerImpl::visitBranchInst(BranchInst &BI) { | |
|
||
// Change br (not X), label True, label False to: br X, label False, True | ||
Value *Cond = BI.getCondition(); | ||
Value *X = nullptr; | ||
Value *X; | ||
if (match(Cond, m_Not(m_Value(X))) && !isa<Constant>(X)) { | ||
// Swap Destinations and condition... | ||
BI.swapSuccessors(); | ||
return replaceOperand(BI, 0, X); | ||
} | ||
|
||
// br (X && !Y), T, F --> br ((X && Y) || !X), F, T | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rotateright
Author
Contributor
|
||
Value *Y; | ||
if (isa<SelectInst>(Cond) && | ||
match(Cond, m_OneUse(m_LogicalAnd(m_Value(X), m_Not(m_Value(Y)))))) { | ||
Value *AndOr = Builder.CreateSelect(X, Y, Builder.getTrue()); | ||
This comment has been minimized.
Sorry, something went wrong.
nikic
Contributor
|
||
BI.swapSuccessors(); | ||
return replaceOperand(BI, 0, AndOr); | ||
} | ||
|
||
// If the condition is irrelevant, remove the use so that other | ||
// transforms on the condition become more effective. | ||
if (!isa<ConstantInt>(Cond) && BI.getSuccessor(0) == BI.getSuccessor(1)) | ||
|
I'm really confused by the RHS of this comment. Did you mean
br (!X || Y), F, T
?