Skip to content

Commit 683a9ac

Browse files
committed
[X86] combineVectorPack - use APInt::truncSSat for PACKSS constant folding. NFC.
Unfortunately PACKUS can't use APInt::truncUSat
1 parent e097619 commit 683a9ac

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47630,16 +47630,12 @@ static SDValue combineVectorPack(SDNode *N, SelectionDAG &DAG,
4763047630
// PACKSS: Truncate signed value with signed saturation.
4763147631
// Source values less than dst minint are saturated to minint.
4763247632
// Source values greater than dst maxint are saturated to maxint.
47633-
if (Val.isSignedIntN(DstBitsPerElt))
47634-
Val = Val.trunc(DstBitsPerElt);
47635-
else if (Val.isNegative())
47636-
Val = APInt::getSignedMinValue(DstBitsPerElt);
47637-
else
47638-
Val = APInt::getSignedMaxValue(DstBitsPerElt);
47633+
Val = Val.truncSSat(DstBitsPerElt);
4763947634
} else {
4764047635
// PACKUS: Truncate signed value with unsigned saturation.
4764147636
// Source values less than zero are saturated to zero.
4764247637
// Source values greater than dst maxuint are saturated to maxuint.
47638+
// NOTE: This is different from APInt::truncUSat.
4764347639
if (Val.isIntN(DstBitsPerElt))
4764447640
Val = Val.trunc(DstBitsPerElt);
4764547641
else if (Val.isNegative())

0 commit comments

Comments
 (0)