@@ -8317,9 +8317,11 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
8317
8317
default :
8318
8318
break ;
8319
8319
case RISCVISD::SELECT_CC: {
8320
- unsigned Tmp = DAG.ComputeNumSignBits (Op.getOperand (3 ), DemandedElts, Depth + 1 );
8320
+ unsigned Tmp =
8321
+ DAG.ComputeNumSignBits (Op.getOperand (3 ), DemandedElts, Depth + 1 );
8321
8322
if (Tmp == 1 ) return 1 ; // Early out.
8322
- unsigned Tmp2 = DAG.ComputeNumSignBits (Op.getOperand (4 ), DemandedElts, Depth + 1 );
8323
+ unsigned Tmp2 =
8324
+ DAG.ComputeNumSignBits (Op.getOperand (4 ), DemandedElts, Depth + 1 );
8323
8325
return std::min (Tmp, Tmp2);
8324
8326
}
8325
8327
case RISCVISD::SLLW:
@@ -8362,15 +8364,18 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
8362
8364
}
8363
8365
break ;
8364
8366
}
8365
- case RISCVISD::VMV_X_S:
8367
+ case RISCVISD::VMV_X_S: {
8366
8368
// The number of sign bits of the scalar result is computed by obtaining the
8367
8369
// element type of the input vector operand, subtracting its width from the
8368
8370
// XLEN, and then adding one (sign bit within the element type). If the
8369
8371
// element type is wider than XLen, the least-significant XLEN bits are
8370
8372
// taken.
8371
- if (Op.getOperand (0 ).getScalarValueSizeInBits () > Subtarget.getXLen ())
8372
- return 1 ;
8373
- return Subtarget.getXLen () - Op.getOperand (0 ).getScalarValueSizeInBits () + 1 ;
8373
+ unsigned XLen = Subtarget.getXLen ();
8374
+ unsigned EltBits = Op.getOperand (0 ).getScalarValueSizeInBits ();
8375
+ if (EltBits <= XLen)
8376
+ return XLen - EltBits + 1 ;
8377
+ break ;
8378
+ }
8374
8379
}
8375
8380
8376
8381
return 1 ;
0 commit comments