diff options
author | David Green <david.green@arm.com> | 2018-10-11 11:28:27 +0000 |
---|---|---|
committer | David Green <david.green@arm.com> | 2018-10-11 11:28:27 +0000 |
commit | 8066198442da16027a646c56d3c87ca0ba3fcb86 (patch) | |
tree | 15e754c1be196cf5135e43c132b35f6195c1b444 /llvm/lib | |
parent | 686ef9214147c048514f579b128bdbd9bbb49504 (diff) | |
download | bcm5719-llvm-8066198442da16027a646c56d3c87ca0ba3fcb86.tar.gz bcm5719-llvm-8066198442da16027a646c56d3c87ca0ba3fcb86.zip |
[InstCombine] Demand bits of UMin
This is the umin alternative to the umax code from rL344237. We use
DeMorgans law on the umax case to bring us to the same thing on umin,
but using countLeadingOnes, not countLeadingZeros.
Differential Revision: https://reviews.llvm.org/D53036
llvm-svn: 344239
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 18a2b2fdbfe..45cacc73d63 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -325,6 +325,16 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, unsigned CTZ = DemandedMask.countTrailingZeros(); if (match(RHS, m_APInt(C)) && CTZ >= C->getActiveBits()) return LHS; + } else if (SPF == SPF_UMIN) { + // UMin(A, C) == A if ... + // The lowest non-zero bit of DemandMask is higher than the highest + // non-one bit of C. + // This comes from using DeMorgans on the above umax example. + const APInt *C; + unsigned CTZ = DemandedMask.countTrailingZeros(); + if (match(RHS, m_APInt(C)) && + CTZ >= C->getBitWidth() - C->countLeadingOnes()) + return LHS; } // If this is a select as part of any other min/max pattern, don't simplify |