[llvm] [InstCombine] Improve coverage of `foldSelectValueEquivalence` for non-constants (PR #94719)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 22 00:26:56 PDT 2024


================
@@ -1308,13 +1310,20 @@ Instruction *InstCombinerImpl::foldSelectValueEquivalence(SelectInst &Sel,
           isGuaranteedNotToBeUndef(V, SQ.AC, &Sel, &DT))
         return replaceOperand(Sel, Swapped ? 2 : 1, V);
 
-      // If NewOp is a constant and OldOp is not replace iff NewOp doesn't
-      // contain and undef elements.
-      if (match(NewOp, m_ImmConstant())) {
----------------
nikic wrote:

Can you just add `|| NewOp == V` to this line and leave everything else alone?

https://github.com/llvm/llvm-project/pull/94719


More information about the llvm-commits mailing list