[InstCombine] Inefficient pattern for high-bits checking 3 (PR38708)
authorRoman Lebedev <lebedev.ri@gmail.com>
Sat, 15 Sep 2018 12:04:13 +0000 (12:04 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sat, 15 Sep 2018 12:04:13 +0000 (12:04 +0000)
commit1b7fc870206a44474ea72b1b6c0c2653582a7987
treed639de43c9de26b17075ce829454c000cbc9684c
parent9e8b4de3b3ab0ad27ef27ce948e00e3a3b26aa3c
[InstCombine] Inefficient pattern for high-bits checking 3 (PR38708)

Summary:
It is sometimes important to check that some newly-computed value
is non-negative and only n bits wide (where n is a variable.)
There are many ways to check that:
https://godbolt.org/z/o4RB8D
The last variant seems best?
(I'm sure there are some other variations i haven't thought of..)

The last (as far i know?) pattern, non-canonical due to the extra use.
https://godbolt.org/z/aCMsPk
https://rise4fun.com/Alive/I6f

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

Reviewers: spatel, craig.topper, RKSimon

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 342321
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-uge-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp-ult-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll