OSDN Git Service

[InstSimplify] Fix missed optimization in simplifyUnsignedRangeCheck()
authorSanjay Patel <spatel@rotateright.com>
Wed, 20 Jun 2018 14:22:49 +0000 (14:22 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 20 Jun 2018 14:22:49 +0000 (14:22 +0000)
commit0da71804c34dea2ab964bd3f3eb1aa68aa5cd251
tree1c98cd3212f7282a57e0614a874807e95f2ad728
parentf4f8a442ba91ab33fd8ba30cc8c66cb65d23783a
[InstSimplify] Fix missed optimization in simplifyUnsignedRangeCheck()

For both operands are unsigned, the following optimizations are valid, and missing:

   1. X > Y && X != 0 --> X > Y
   2. X > Y || X != 0 --> X != 0
   3. X <= Y || X != 0 --> true
   4. X <= Y || X == 0 --> X <= Y
   5. X > Y && X == 0 --> false

unsigned foo(unsigned x, unsigned y) { return x > y && x != 0; }
should fold to x > y, but I found we haven't done it right now.
besides, unsigned foo(unsigned x, unsigned y) { return x < y && y != 0; }
Has been folded to x < y, so there may be a bug.

Patch by: Li Jia He!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335129 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/AndOrXor.ll