diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-08-24 13:55:55 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-24 13:55:55 +0000 |
commit | 8e297749c14690290099f0bfe6010b70c5e340d0 (patch) | |
tree | 92372564068f716bc4a715153bb7ab15a27df9b9 /llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | |
parent | a7ed090bba0261162ed1dd018be8a25ec4ba0f81 (diff) | |
download | bcm5719-llvm-8e297749c14690290099f0bfe6010b70c5e340d0.tar.gz bcm5719-llvm-8e297749c14690290099f0bfe6010b70c5e340d0.zip |
[InstCombine] add assert and explanatory comment for fold removed in r279568; NFC
I deleted a fold from InstCombine at:
https://reviews.llvm.org/rL279568
because it (like any InstCombine to a constant?) should always happen in InstSimplify,
however, it's not obvious what the assumptions are in the remaining code.
Add a comment and assert to make it clearer.
Differential Revision: https://reviews.llvm.org/D23819
llvm-svn: 279626
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index eee1243338e..0d23ea0a948 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2041,6 +2041,13 @@ Instruction *InstCombiner::foldICmpShrConstant(ICmpInst &Cmp, return Res; } + // If the comparison constant changes with the shift, the comparison cannot + // succeed (bits of the comparison constant cannot match the shifted value). + // This should be known by InstSimplify and already be folded to true/false. + assert(((IsAShr && C->shl(ShAmtVal).ashr(ShAmtVal) == *C) || + (!IsAShr && C->shl(ShAmtVal).lshr(ShAmtVal) == *C)) && + "Expected icmp+shr simplify did not occur."); + // Check if the bits shifted out are known to be zero. If so, we can compare // against the unshifted value: // (X & 4) >> 1 == 2 --> (X & 4) == 4. |