HomePhabricator

[InstCombine] Fold x & (-1 >> y) == x to x u<= (-1 >> y)

Description

[InstCombine] Fold x & (-1 >> y) == x to x u<= (-1 >> y)

Summary:
https://bugs.llvm.org/show_bug.cgi?id=38123

This pattern will be produced by Implicit Integer Truncation sanitizer,
https://reviews.llvm.org/D48958
https://bugs.llvm.org/show_bug.cgi?id=21530
in unsigned case, therefore it is probably a good idea to improve it.

https://rise4fun.com/Alive/Rny
^ there are more opportunities for folds, i will follow up with them afterwards.

Caveat: this somehow exposes a missing opportunities
in test/Transforms/InstCombine/icmp-logical.ll
It seems, the problem is in foldLogOpOfMaskedICmps() in InstCombineAndOrXor.cpp.
But i'm not quite sure what is wrong, because it calls getMaskedTypeForICmpPair(),
which calls decomposeBitTestICmp() which should already work for these cases...
As @spatel notes in https://reviews.llvm.org/D49179#1158760,
that code is a rather complex mess, so we'll let it slide.

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: yamauchi, majnemer, t.p.northover, llvm-commits

Differential Revision: https://reviews.llvm.org/D49179

Details

Committed
lebedevriJul 11 2018, 12:05 PM
Reviewer
spatel
Differential Revision
D49179: [InstCombine] Fold x & (-1 >> y) == x to x u<= (-1 >> y)
Parents
rL336833: Revert r336830: [FileCheck] Don't permit overlapping CHECK-DAG
Branches
Unknown
Tags
Unknown