summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-04-12 06:49:28 +0000
committerCraig Topper <craig.topper@intel.com>2019-04-12 06:49:28 +0000
commit3b1239d2a86ffc6158130f57a893b64a5221d659 (patch)
treefefd95416fc72b98853af1801562bb93a5ac2f6c /llvm/lib/CodeGen
parent6f8f98ce8de7c0e4ebd7fa2e1fd9507fe8d1c317 (diff)
downloadbcm5719-llvm-3b1239d2a86ffc6158130f57a893b64a5221d659.tar.gz
bcm5719-llvm-3b1239d2a86ffc6158130f57a893b64a5221d659.zip
[TargetLowering][X86] Teach SimplifyDemandedBits to use ShrinkDemandedOp on ISD::SHL nodes.
If the upper bits of the SHL result aren't used, we might be able to use a narrower shift. For example, on X86 this can turn a 64-bit into 32-bit enabling a smaller encoding. Differential Revision: https://reviews.llvm.org/D60358 llvm-svn: 358257
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 4d5dae7d960..636fa6c1dab 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -961,6 +961,12 @@ bool TargetLowering::SimplifyDemandedBits(
Known, TLO, Depth + 1))
return true;
+ // Try shrinking the operation as long as the shift amount will still be
+ // in range.
+ if ((ShAmt < DemandedBits.getActiveBits()) &&
+ ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO))
+ return true;
+
// Convert (shl (anyext x, c)) to (anyext (shl x, c)) if the high bits
// are not demanded. This will likely allow the anyext to be folded away.
if (Op0.getOpcode() == ISD::ANY_EXTEND) {
OpenPOWER on IntegriCloud