The transform in question:
icmp (and (trunc W), C2), C1 -> icmp (and W, C2'), C1'
...is still not enabled for vectors, thus no functional change intended.
It's not clear to me if this is a good transform for vectors or even
scalars in general. Changing that behavior may be a follow-on patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280627 91177308-0d34-0410-b5e6-96231b3b80d8
While removing a scalar shackle from an icmp fold, I noticed that I couldn't find any tests to trigger
this code path.
The 'and' shrinking transform should be handled by InstCombiner::foldCastedBitwiseLogic()
or eliminated with InstSimplify. The icmp narrowing is part of InstCombiner::foldICmpWithCastAndCast().
Differential Revision: https://reviews.llvm.org/D24031
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280370 91177308-0d34-0410-b5e6-96231b3b80d8
This is prep work before changing the callers to also use APInt which will
allow folds for splat vectors. Currently, the callers have ConstantInt
guards in place, so no functional change intended with this commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280282 91177308-0d34-0410-b5e6-96231b3b80d8
These folds already have tests for scalar and vector types, except
for the vector div-by-0 case, so I'm adding tests for that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280115 91177308-0d34-0410-b5e6-96231b3b80d8
1. Fix comments to match variable names
2. Remove redundant CmpRHS variable
3. Add FIXME to replace some checks with asserts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280112 91177308-0d34-0410-b5e6-96231b3b80d8
Like other recent changes near here, the goal is to allow vector types for
all of these folds. Splitting things up makes it easier to incrementally
enhance the code and easier to read.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279851 91177308-0d34-0410-b5e6-96231b3b80d8
1. Early exit to reduce indent
2. Fix comments and variable names to match
3. Reformat comments / clang-format code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279837 91177308-0d34-0410-b5e6-96231b3b80d8
Removing the redundant 'CmpRHSV' local variable exposes a bug in the caller
foldICmpShrConstant() - it was sending in the div constant instead of the
cmp constant. But I have not been able to expose this in a regression test
yet - the affected folds all appear to be handled before we ever reach this
code. I'll keep trying to find a case as I make changes to allow vector folds
in both functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279828 91177308-0d34-0410-b5e6-96231b3b80d8
There was no logic in foldICmpDivConstant, so no need for a separate function.
The code is directly copy/pasted, so further cleanups to follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279685 91177308-0d34-0410-b5e6-96231b3b80d8
There will only be 3 lines of code in foldICmpShrConst() when the cleanup is done,
so it doesn't make much sense to have a separate function for a single fold.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279575 91177308-0d34-0410-b5e6-96231b3b80d8
The callers still have ConstantInt guards, so there is no functional change
intended from this change. But relaxing the callers will allow more folds
for vector types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279396 91177308-0d34-0410-b5e6-96231b3b80d8
This is a partial enablement (move the ConstantInt guard down) because there are many
different folds here and one of the later ones will require reworking 'isSignBitCheck'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279339 91177308-0d34-0410-b5e6-96231b3b80d8
Specifically, this is done near the end of "SimplifyICmpInst" using
computeKnownBits() as the broader solution. There are even vector
tests (yay!) for this in test/Transforms/InstSimplify/compare.ll.
I considered putting an assert here instead of just deleting, but
then we could assert every possible fold in InstSimplify in
InstCombine, so...less is more?
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279300 91177308-0d34-0410-b5e6-96231b3b80d8
The intended transform is:
// Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0
// -> and (icmp eq P, null), (icmp eq Q, null).
P and Q are both pointer types, but may have different types. We need
two calls to getNullValue() to make the icmps.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279271 91177308-0d34-0410-b5e6-96231b3b80d8
Of course, we really need to refactor and fix all of the cmp predicates,
but this one is interesting because without it, we later perform an
information-losing transform of icmp (shl 1, Y), C, and we can't recover
the better fold.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279263 91177308-0d34-0410-b5e6-96231b3b80d8
Clean up the existing code by:
1. Renaming variables
2. Adding local variables
3. Making it vector-safe
This is still guarded by a ConstantInt check, so no functional change is intended.
But this should be ready to go: if we move the ConstantInt check down, all of
these folds should do the right thing for vector types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279150 91177308-0d34-0410-b5e6-96231b3b80d8
This will enable vector splat folding, but NFC until the callers
have their ConstantInt restrictions removed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279072 91177308-0d34-0410-b5e6-96231b3b80d8
Use m_APInt for the xor constant, but this is all still guarded by the initial
ConstantInt check, so no vector types should make it in here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278957 91177308-0d34-0410-b5e6-96231b3b80d8
1. Change variable names
2. Use local variables to reduce code
3. Use ? instead of if/else
4. Use the APInt variable instead of 'RHS' so the removal of the FIXME code will be direct
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278944 91177308-0d34-0410-b5e6-96231b3b80d8
This is a mechanical change of comments in switches like fallthrough,
fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278902 91177308-0d34-0410-b5e6-96231b3b80d8