Skip to content

Commit 8e6db7e

Browse files
authored
[RISCV] Fix a crash from trying to truncate an FP type in lowerBuildV… (#67488)
…ectorOfConstants. ComputeNumSignBits can return an answer for FP constants based on bitcasting them to int. Check for an integer type so we don't create an illegal truncate. We could support this case with bitcasts, but I leave that to a separate patch.
1 parent 5ffbdd9 commit 8e6db7e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ static SDValue lowerBuildVectorOfConstants(SDValue Op, SelectionDAG &DAG,
35263526
// narrow vector is known to materialize cheaply.
35273527
// TODO: We really should be costing the smaller vector. There are
35283528
// profitable cases this misses.
3529-
if (EltBitSize > 8 &&
3529+
if (EltBitSize > 8 && VT.isInteger() &&
35303530
(NumElts <= 4 || VT.getSizeInBits() > Subtarget.getRealMinVLen())) {
35313531
unsigned SignBits = DAG.ComputeNumSignBits(Op);
35323532
if (EltBitSize - SignBits < 8) {

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,3 +1076,10 @@ define <32 x double> @buildvec_v32f64(double %e0, double %e1, double %e2, double
10761076
%v31 = insertelement <32 x double> %v30, double %e31, i64 31
10771077
ret <32 x double> %v31
10781078
}
1079+
1080+
; FIXME: These constants have enough sign bits that we could use vmv.v.x/i and
1081+
; vsext, but we don't support this for FP yet.
1082+
define <2 x float> @signbits() {
1083+
entry:
1084+
ret <2 x float> <float 0x36A0000000000000, float 0.000000e+00>
1085+
}

0 commit comments

Comments
 (0)