[llvm] r280300 - [InstCombine] allow icmp (shr exact X, C2), C fold for splat constant vectors
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 15:18:44 PDT 2016
Author: spatel
Date: Wed Aug 31 17:18:43 2016
New Revision: 280300
URL: http://llvm.org/viewvc/llvm-project?rev=280300&view=rev
Log:
[InstCombine] allow icmp (shr exact X, C2), C fold for splat constant vectors
The enhancement to foldICmpDivConstant ( http://llvm.org/viewvc/llvm-project?view=revision&revision=280299 )
allows us to remove the ConstantInt check; no other changes needed.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/exact.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=280300&r1=280299&r2=280300&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Aug 31 17:18:43 2016
@@ -1876,11 +1876,6 @@ Instruction *InstCombiner::foldICmpShrCo
if (IsAShr && (!Shr->isExact() || ShAmtVal == TypeBits - 1))
return nullptr;
- // FIXME: This check restricts this fold to scalar types.
- ConstantInt *ShAmt = dyn_cast<ConstantInt>(Shr->getOperand(1));
- if (!ShAmt)
- return nullptr;
-
// Revisit the shift (to delete it).
Worklist.Add(Shr);
Modified: llvm/trunk/test/Transforms/InstCombine/exact.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/exact.ll?rev=280300&r1=280299&r2=280300&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/exact.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/exact.ll Wed Aug 31 17:18:43 2016
@@ -120,11 +120,9 @@ define i1 @ashr_icmp2(i64 %X) {
ret i1 %Z
}
-; FIXME: Vectors should fold the same way.
define <2 x i1> @ashr_icmp2_vec(<2 x i64> %X) {
; CHECK-LABEL: @ashr_icmp2_vec(
-; CHECK-NEXT: [[Y:%.*]] = ashr exact <2 x i64> %X, <i64 2, i64 2>
-; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i64> [[Y]], <i64 4, i64 4>
+; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i64> %X, <i64 16, i64 16>
; CHECK-NEXT: ret <2 x i1> [[Z]]
;
%Y = ashr exact <2 x i64> %X, <i64 2, i64 2>
More information about the llvm-commits
mailing list