[llvm] 2fbc40d - [RISCV] Split compound if statement to fix a crash.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 11:53:43 PDT 2024
Author: Craig Topper
Date: 2024-03-26T11:53:17-07:00
New Revision: 2fbc40d36dd8e21fab4cc6cb43984baaa39bcd59
URL: https://github.com/llvm/llvm-project/commit/2fbc40d36dd8e21fab4cc6cb43984baaa39bcd59
DIFF: https://github.com/llvm/llvm-project/commit/2fbc40d36dd8e21fab4cc6cb43984baaa39bcd59.diff
LOG: [RISCV] Split compound if statement to fix a crash.
We're not allowed to call getELEN when the vector extension
is not enabled. If we're looking at a vector type, isTypeLegal would
only return true if the vector extensions are enabled. So early out
for non-vector types before we call isTypeLegal and getELEN.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 4bcb9acdae19c7..df289be189328e 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -898,12 +898,15 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
TTI::TargetCostKind CostKind,
const Instruction *I) {
bool IsVectorType = isa<VectorType>(Dst) && isa<VectorType>(Src);
+ if (!IsVectorType)
+ return BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
+
bool IsTypeLegal = isTypeLegal(Src) && isTypeLegal(Dst) &&
(Src->getScalarSizeInBits() <= ST->getELen()) &&
(Dst->getScalarSizeInBits() <= ST->getELen());
// FIXME: Need to compute legalizing cost for illegal types.
- if (!IsVectorType || !IsTypeLegal)
+ if (!IsTypeLegal)
return BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
int ISD = TLI->InstructionOpcodeToISD(Opcode);
More information about the llvm-commits
mailing list