Skip to content
Commit 57590d1d authored by Noah Goldstein's avatar Noah Goldstein
Browse files

[ValueTracking] Apply the isKnownNonZero techniques in `ashr`/`lshl` to `shl` and vice-versa

For all shifts we can apply the same two optimizations.

    1) `ShiftOp(KnownVal.One, Max(KnownCnt)) != 0`
        -> result is non-zero
    2) If already known `Val != 0` and we only shift out zeros (based
       on `Max(KnownCnt)`)
        -> result is non-zero

The former exists for `shl` and the latter (for constant `Cnt`) exists
for `ashr`/`lshr`.

This patch improves the latter to use `Max(KnownCnt)` instead of
relying on a constant shift `Cnt` and applies both techniques for all
shift ops.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D148404
parent 107a5e2b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment