[PATCH] D52001: [InstCombine] Inefficient pattern for high-bits checking 2 (PR38708)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 13:14:58 PDT 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, craig.topper, RKSimon.

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..)

More complicated, canonical pattern:
https://rise4fun.com/Alive/uhA

We do need to have two `switch()`'es like this,
to not mismatch the swappable predicates.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D52001

Files:
  lib/Transforms/InstCombine/InstCombineCompares.cpp
  test/Transforms/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll
  test/Transforms/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52001.165138.patch
Type: text/x-patch
Size: 10679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180912/a53e7dc2/attachment.bin>


More information about the llvm-commits mailing list