[llvm] [X86] Use NSW/NUW flags on ISD::TRUNCATE nodes to improve X86 PACKSS/PACKUS lowering (PR #123956)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 04:59:44 PST 2025
================
@@ -20865,7 +20866,8 @@ static SDValue matchTruncateWithPACK(unsigned &PackOpcode, EVT DstVT,
// e.g. Masks, zext_in_reg, etc.
// Pre-SSE41 we can only use PACKUSWB.
KnownBits Known = DAG.computeKnownBits(In);
- if ((NumSrcEltBits - NumPackedZeroBits) <= Known.countMinLeadingZeros()) {
+ if ((Flags.hasNoUnsignedWrap() && NumDstEltBits <= NumPackedZeroBits) ||
+ (NumSrcEltBits - NumPackedZeroBits) <= Known.countMinLeadingZeros()) {
----------------
phoebewang wrote:
Makes sense to me. Thanks for the investigation!
https://github.com/llvm/llvm-project/pull/123956
More information about the llvm-commits
mailing list