summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-04-16 19:05:49 +0000
committerNikita Popov <nikita.ppv@gmail.com>2019-04-16 19:05:49 +0000
commit5ecd6a48b938b37822cbfd9f309bb14e56043d38 (patch)
treeb69d13f4edbbbf65c2c1ed00f8794cd89c8e986b /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
parentf700081a7d977fd132b2fdaf8609627ca12e92b9 (diff)
downloadbcm5719-llvm-5ecd6a48b938b37822cbfd9f309bb14e56043d38.tar.gz
bcm5719-llvm-5ecd6a48b938b37822cbfd9f309bb14e56043d38.zip
[InstCombine] Prune fshl/fshr with masked operands
If a constant shift amount is used, then only some of the LHS/RHS operand bits are demanded and we may be able to simplify based on that. InstCombineSimplifyDemanded already had the necessary support for that, we just weren't calling it with fshl/fshr as root. In particular, this allows us to relax some masked funnel shifts into simple shifts, as shown in the tests. Patch by Shawn Landden. Differential Revision: https://reviews.llvm.org/D60660 llvm-svn: 358515
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index d8b188ab8f8..dfdf677a797 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2085,6 +2085,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
ConstantExpr::getSub(WidthC, ShAmtC));
}
+ // Left or right might be masked.
+ if (SimplifyDemandedInstructionBits(*II))
+ return &CI;
+
// The shift amount (operand 2) of a funnel shift is modulo the bitwidth,
// so only the low bits of the shift amount are demanded if the bitwidth is
// a power-of-2.
OpenPOWER on IntegriCloud