diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-08-04 22:19:27 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-04 22:19:27 +0000 |
| commit | 3bade138b5edb59a472996aeb21fdf9b29d98209 (patch) | |
| tree | fc8b730d9979a48508fd65df90cd444c3f493283 | |
| parent | 8daab7582bef4e5d887fc214c9f64dfee122349e (diff) | |
| download | bcm5719-llvm-3bade138b5edb59a472996aeb21fdf9b29d98209.tar.gz bcm5719-llvm-3bade138b5edb59a472996aeb21fdf9b29d98209.zip | |
[InstCombine] use m_APInt to allow icmp eq (mul X, C1), C2 folds for splat constant vectors
This concludes the splat vector enhancements for foldICmpEqualityWithConstant().
Other commits in this series:
https://reviews.llvm.org/rL277762
https://reviews.llvm.org/rL277752
https://reviews.llvm.org/rL277738
https://reviews.llvm.org/rL277731
https://reviews.llvm.org/rL277659
https://reviews.llvm.org/rL277638
https://reviews.llvm.org/rL277629
llvm-svn: 277779
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 11 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 3 |
2 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 6c795db6669..778a75fb977 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2314,14 +2314,13 @@ Instruction *InstCombiner::foldICmpEqualityWithConstant(ICmpInst &ICI) { } case Instruction::Mul: if (*RHSV == 0 && BO->hasNoSignedWrap()) { - // FIXME: Vectors are excluded by ConstantInt. - if (ConstantInt *BOC = dyn_cast<ConstantInt>(BOp1)) { - // The trivial case (mul X, 0) is handled by InstSimplify + const APInt *BOC; + if (match(BOp1, m_APInt(BOC)) && *BOC != 0) { + // The trivial case (mul X, 0) is handled by InstSimplify. // General case : (mul X, C) != 0 iff X != 0 // (mul X, C) == 0 iff X == 0 - if (!BOC->isZero()) - return new ICmpInst(ICI.getPredicate(), BOp0, - Constant::getNullValue(RHS->getType())); + return new ICmpInst(ICI.getPredicate(), BOp0, + Constant::getNullValue(RHS->getType())); } } break; diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 88cf0cdd943..27ae64eb5d3 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -1207,8 +1207,7 @@ define i1 @icmp_mul_neq0(i32 %x) { ; FIXME: Vectors should fold the same way. define <2 x i1> @icmp_mul_neq0_vec(<2 x i32> %x) { ; CHECK-LABEL: @icmp_mul_neq0_vec( -; CHECK-NEXT: [[MUL:%.*]] = mul nsw <2 x i32> %x, <i32 -12, i32 -12> -; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[MUL]], zeroinitializer +; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> %x, zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[CMP]] ; %mul = mul nsw <2 x i32> %x, <i32 -12, i32 -12> |

