diff options
author | Philip Reames <preames@rivosinc.com> | 2024-02-08 11:28:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-08 11:28:06 -0800 |
commit | d0f72f88606b78447fb7b61214651854c787c26f (patch) | |
tree | 1239cad761991a183f49e5eaa1a716702035fa38 /llvm/lib | |
parent | 88e52511ca71165f1ff3d7c42229aeacb2c16db3 (diff) | |
download | llvm-d0f72f88606b78447fb7b61214651854c787c26f.zip llvm-d0f72f88606b78447fb7b61214651854c787c26f.tar.gz llvm-d0f72f88606b78447fb7b61214651854c787c26f.tar.bz2 |
[RISCV] Consider truncate semantics in performBUILD_VECTORCombine (#81168)
Fixes https://github.com/llvm/llvm-project/issues/80910.
Per the documentation in ISDOpcodes.h, for BUILD_VECTOR "The types of
the operands must match the vector element type, except that integer
types are allowed to be larger than the element type, in which case the
operands are implicitly truncated."
This transform was assuming that the scalar operand type matched the
result type. This resulted in essentially performing a truncate before a
binop, instead of after. As demonstrated by the test case changes, this
is often not legal.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 27037f4..0799cc2 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -14956,6 +14956,11 @@ static SDValue performBUILD_VECTORCombine(SDNode *N, SelectionDAG &DAG, if (!TLI.isOperationLegalOrCustom(Opcode, VT) || !TLI.isTypeLegal(VT)) return SDValue(); + // This BUILD_VECTOR involves an implicit truncation, and sinking + // truncates through binops is non-trivial. + if (N->op_begin()->getValueType() != VT.getVectorElementType()) + return SDValue(); + SmallVector<SDValue> LHSOps; SmallVector<SDValue> RHSOps; for (SDValue Op : N->ops()) { @@ -14983,6 +14988,7 @@ static SDValue performBUILD_VECTORCombine(SDNode *N, SelectionDAG &DAG, // have different LHS and RHS types. if (Op.getOperand(0).getValueType() != Op.getOperand(1).getValueType()) return SDValue(); + RHSOps.push_back(Op.getOperand(1)); } |