[PATCH] D103246: [SelectionDAG] Extend FoldConstantVectorArithmetic to SPLAT_VECTOR

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 28 10:31:14 PDT 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5301
+    return Op.isUndef() || Op.getOpcode() == ISD::CONDCODE ||
+           Op.getOpcode() == ISD::SPLAT_VECTOR || (BV && BV->isConstant());
   };
----------------
Why don't we need to check that the splat vector operand is constant/undef like we do for build_vector?


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5371
 
-  SDValue V = getBuildVector(VT, DL, ScalarResults);
+  SDValue V = NumElts.isScalable() ? getSplatVector(VT, DL, ScalarResults[0])
+                                   : getBuildVector(VT, DL, ScalarResults);
----------------
When I made similar changes to FoldConstantArithmetic, I was asked to create a splat vector if the input was splat vectors. Should we be consistent? Though maybe it's harder because you're dealing with more than 2 sources?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103246/new/

https://reviews.llvm.org/D103246



More information about the llvm-commits mailing list