[llvm] 8f4ffbb - [RISCV] Create new build vector instead of relying on getNode constan… (#67944)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 09:13:38 PDT 2023
Author: Craig Topper
Date: 2023-10-02T09:13:33-07:00
New Revision: 8f4ffbbaf7ba6bde6f3f2731669b28b1c9a46505
URL: https://github.com/llvm/llvm-project/commit/8f4ffbbaf7ba6bde6f3f2731669b28b1c9a46505
DIFF: https://github.com/llvm/llvm-project/commit/8f4ffbbaf7ba6bde6f3f2731669b28b1c9a46505.diff
LOG: [RISCV] Create new build vector instead of relying on getNode constan… (#67944)
…t folding.
We want to create a build_vector with narrower elements here. Normally
getNode on the ISD::TRUNCATE will constant fold this to a new
BUILD_VECTOR. If it doesn't constant fold, we end up with a cycle in the
DAG because we truncate the node we are replacing. Constant folding can
fail if one of the elements is an opaque constant.
The failing case I saw involved an opaque constant created by a memset
that was expanded. Not sure exactly what happened after that.
This patch creates a new BUILD_VECTOR with the new type directly.
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 dd10bca3598b7b6..a044aa7f4a8d272 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -3530,8 +3530,8 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
(NumElts <= 4 || VT.getSizeInBits() > Subtarget.getRealMinVLen())) {
unsigned SignBits = DAG.ComputeNumSignBits(Op);
if (EltBitSize - SignBits < 8) {
- SDValue Source =
- DAG.getNode(ISD::TRUNCATE, DL, VT.changeVectorElementType(MVT::i8), Op);
+ SDValue Source = DAG.getBuildVector(VT.changeVectorElementType(MVT::i8),
+ DL, Op->ops());
Source = convertToScalableVector(ContainerVT.changeVectorElementType(MVT::i8),
Source, DAG, Subtarget);
SDValue Res = DAG.getNode(RISCVISD::VSEXT_VL, DL, ContainerVT, Source, Mask, VL);
More information about the llvm-commits
mailing list