Closed bjope closed 1 year ago
@llvm/issue-subscribers-backend-risc-v
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -13475,11 +13475,12 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
ISD::isBuildVectorOfConstantSDNodes(Val.getNode())) {
// Get the constant vector bits
APInt NewC(Val.getValueSizeInBits(), 0);
+ uint64_t EleSize = Val.getScalarValueSizeInBits();
for (unsigned i = 0; i < Val.getNumOperands(); i++) {
if (Val.getOperand(i).isUndef())
continue;
- NewC.insertBits(Val.getConstantOperandAPInt(i),
- i * Val.getScalarValueSizeInBits());
+ NewC.insertBits(Val.getConstantOperandAPInt(i).trunc(EleSize),
+ i * EleSize);
}
This IR
And running
llc -mtriple riscv64 -mattr=+zve64x
results inThis was found when experimenting to create a reproducer for a different bug seen after https://reviews.llvm.org/D156349 . So it's handwritten IR. No idea if this would be common in reality.
Here is a Godbolt example: https://godbolt.org/z/Yo5d7o84q