@@ -8317,9 +8317,11 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
83178317 default :
83188318 break ;
83198319 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 );
83218322 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 );
83238325 return std::min (Tmp, Tmp2);
83248326 }
83258327 case RISCVISD::SLLW:
@@ -8362,15 +8364,18 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
83628364 }
83638365 break ;
83648366 }
8365- case RISCVISD::VMV_X_S:
8367+ case RISCVISD::VMV_X_S: {
83668368 // The number of sign bits of the scalar result is computed by obtaining the
83678369 // element type of the input vector operand, subtracting its width from the
83688370 // XLEN, and then adding one (sign bit within the element type). If the
83698371 // element type is wider than XLen, the least-significant XLEN bits are
83708372 // 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+ }
83748379 }
83758380
83768381 return 1 ;
0 commit comments