[llvm] [DAGCombiner][RISCV] Handle truncating splats in isNeutralConstant (PR #87338)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 2 05:04:53 PDT 2024


================
@@ -11549,30 +11549,31 @@ bool llvm::isNeutralConstant(unsigned Opcode, SDNodeFlags Flags, SDValue V,
                              unsigned OperandNo) {
   // NOTE: The cases should match with IR's ConstantExpr::getBinOpIdentity().
   // TODO: Target-specific opcodes could be added.
-  if (auto *Const = isConstOrConstSplat(V)) {
+  if (auto *ConstV = isConstOrConstSplat(V, false, true)) {
+    APInt Const = ConstV->getAPIntValue().trunc(V.getScalarValueSizeInBits());
----------------
dtcxzyw wrote:

`combineBinOpToReduce` also uses `isNeutralConstant`.


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


More information about the llvm-commits mailing list