diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-04-07 10:40:01 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-04-07 10:40:01 +0000 |
commit | 07adb6abdadfed379a9998e53beb82ce1e253b0e (patch) | |
tree | a1656b1a8d452b69f8cd08a3767a00526756e571 /llvm/lib | |
parent | 47a7662e29b669358e8b8d193f59e5c8d68568e8 (diff) | |
download | bcm5719-llvm-07adb6abdadfed379a9998e53beb82ce1e253b0e.tar.gz bcm5719-llvm-07adb6abdadfed379a9998e53beb82ce1e253b0e.zip |
[X86][SSE] SimplifyDemandedBitsForTargetNode - Add initial PACKSS support
In the case where we only want the sign bit (e.g. when using PACKSS truncation of comparison results for MOVMSK) then we can just demand the sign bit of the source operands.
This makes use of the fact that PACKSS saturates out of range values to the min/max int values - so the sign bit is always preserved.
Differential Revision: https://reviews.llvm.org/D60333
llvm-svn: 357859
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index dd694281521..217c0e6ce48 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -33508,6 +33508,25 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode( } break; } + case X86ISD::PACKSS: + // PACKSS saturates to MIN/MAX integer values. So if we just want the + // sign bit then we can just ask for the source operands sign bit. + // TODO - add known bits handling. + if (OriginalDemandedBits.isSignMask()) { + APInt DemandedLHS, DemandedRHS; + getPackDemandedElts(VT, OriginalDemandedElts, DemandedLHS, DemandedRHS); + + KnownBits KnownLHS, KnownRHS; + APInt SignMask = APInt::getSignMask(BitWidth * 2); + if (SimplifyDemandedBits(Op.getOperand(0), SignMask, DemandedLHS, + KnownLHS, TLO, Depth + 1)) + return true; + if (SimplifyDemandedBits(Op.getOperand(1), SignMask, DemandedRHS, + KnownRHS, TLO, Depth + 1)) + return true; + } + // TODO - add general PACKSS/PACKUS SimplifyDemandedBits support. + break; case X86ISD::PCMPGT: // icmp sgt(0, R) == ashr(R, BitWidth-1). // iff we only need the sign bit then we can use R directly. |