[llvm] d287051 - [InstCombine] Avoid ConstantExpr::get() in vector binop fold (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 08:20:22 PDT 2022


Author: Nikita Popov
Date: 2022-07-08T17:20:14+02:00
New Revision: d2870514048017231c097dfa50d628380d8c73f2

URL: https://github.com/llvm/llvm-project/commit/d2870514048017231c097dfa50d628380d8c73f2
DIFF: https://github.com/llvm/llvm-project/commit/d2870514048017231c097dfa50d628380d8c73f2.diff

LOG: [InstCombine] Avoid ConstantExpr::get() in vector binop fold (NFCI)

Use the ConstantFoldBinaryOpOperands() API instead. This case
would bail out on a non-folded result anyway.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 6c2729613f6a..75520a0c8d5f 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1777,9 +1777,10 @@ Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
       //       for target-independent shuffle creation.
       if (I >= SrcVecNumElts || ShMask[I] < 0) {
         Constant *MaybeUndef =
-            ConstOp1 ? ConstantExpr::get(Opcode, UndefScalar, CElt)
-                     : ConstantExpr::get(Opcode, CElt, UndefScalar);
-        if (!match(MaybeUndef, m_Undef())) {
+            ConstOp1
+                ? ConstantFoldBinaryOpOperands(Opcode, UndefScalar, CElt, DL)
+                : ConstantFoldBinaryOpOperands(Opcode, CElt, UndefScalar, DL);
+        if (!MaybeUndef || !match(MaybeUndef, m_Undef())) {
           MayChange = false;
           break;
         }


        


More information about the llvm-commits mailing list