[llvm-branch-commits] [llvm] a003f26 - [llvm] Prevent infinite loop in InstCombine of select statements
Tres Popp via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 19 01:36:19 PST 2021
Author: Tres Popp
Date: 2021-01-19T10:31:48+01:00
New Revision: a003f26539cf4db744655e76c41f4c4a8913f116
URL: https://github.com/llvm/llvm-project/commit/a003f26539cf4db744655e76c41f4c4a8913f116
DIFF: https://github.com/llvm/llvm-project/commit/a003f26539cf4db744655e76c41f4c4a8913f116.diff
LOG: [llvm] Prevent infinite loop in InstCombine of select statements
This fixes an issue where the RHS and LHS the comparison operation
creating the predicate were swapped back and forth forever.
Differential Revision: https://reviews.llvm.org/D94934
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 9360adc2d3ad..9870abb3b6cb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1123,7 +1123,7 @@ Instruction *InstCombinerImpl::foldSelectValueEquivalence(SelectInst &Sel,
// else. Only do this if CmpRHS is a constant, as profitability is not
// clear for other cases.
// FIXME: The replacement could be performed recursively.
- if (isa<Constant>(CmpRHS) && !isa<ConstantExpr>(CmpRHS))
+ if (match(CmpRHS, m_ImmConstant()) && !match(CmpLHS, m_ImmConstant()))
if (auto *I = dyn_cast<Instruction>(TrueVal))
if (I->hasOneUse())
for (Use &U : I->operands())
More information about the llvm-branch-commits
mailing list