[llvm] a1e8971 - [RISCV] Strengthen INSERT_SUBVECTOR check in combineBinOpToReduce.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 17:47:55 PDT 2023


Author: Craig Topper
Date: 2023-04-24T17:41:09-07:00
New Revision: a1e89710d9fb8d4eb90083d476bd5d77215a960e

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

LOG: [RISCV] Strengthen INSERT_SUBVECTOR check in combineBinOpToReduce.

It's not enough for the vector we're inserting into to be undef.
We also need to be inserting into the lowest subvector.

Spotted by inspection while trying to figure out why this doesn't
work for vp.reduce.fadd.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index d23d4962eb833..897a8a69142a4 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -9126,7 +9126,8 @@ static SDValue combineBinOpToReduce(SDNode *N, SelectionDAG &DAG,
   SDValue ScalarV = Reduce.getOperand(2);
   EVT ScalarVT = ScalarV.getValueType();
   if (ScalarV.getOpcode() == ISD::INSERT_SUBVECTOR &&
-      ScalarV.getOperand(0)->isUndef())
+      ScalarV.getOperand(0)->isUndef() &&
+      isNullConstant(ScalarV.getOperand(2)))
     ScalarV = ScalarV.getOperand(1);
 
   // Make sure that ScalarV is a splat with VL=1.


        


More information about the llvm-commits mailing list