[PATCH] D45856: [InstCombine] Support BitTests in ThreeWayComparison. General case, part 2

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 18:37:10 PDT 2018


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

In this patch we continue supporting BitTests of the highest bit in the ThreeWayComparison
matcher in the InstCombine (see problem's description in the message of https://reviews.llvm.org/D45854).

This patch adds support for the transform of

  %c2 = icmp slt %a, 0
  %select1 = select %c2, %Less, %Greater

to

  (%a s>> 31) - (%Less - %Greater) | %Greater

which is an alternative to

  (%a s>> 31) - (%Less - %Greater) + %Greater

which applies if `(%Less - %Greater) & %Greater == 0`.

This is a part of fix of the bug 37147.


https://reviews.llvm.org/D45856

Files:
  lib/Transforms/InstCombine/InstCombineCompares.cpp
  test/Transforms/InstCombine/three-way-comparison.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45856.143213.patch
Type: text/x-patch
Size: 3576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180420/986bbc95/attachment.bin>


More information about the llvm-commits mailing list