[llvm] r299915 - [InstCombine] Support weird size element types in dyn_castNegVal.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 22:42:47 PDT 2017
Author: ctopper
Date: Tue Apr 11 00:42:47 2017
New Revision: 299915
URL: http://llvm.org/viewvc/llvm-project?rev=299915&view=rev
Log:
[InstCombine] Support weird size element types in dyn_castNegVal.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/2008-05-22-NegValVector.ll
llvm/trunk/test/Transforms/InstCombine/rem.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=299915&r1=299914&r2=299915&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Tue Apr 11 00:42:47 2017
@@ -726,6 +726,10 @@ Value *InstCombiner::dyn_castNegVal(Valu
if (C->getType()->getElementType()->isIntegerTy())
return ConstantExpr::getNeg(C);
+ if (ConstantVector *C = dyn_cast<ConstantVector>(V))
+ if (C->getType()->getElementType()->isIntegerTy())
+ return ConstantExpr::getNeg(C);
+
return nullptr;
}
Modified: llvm/trunk/test/Transforms/InstCombine/2008-05-22-NegValVector.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-05-22-NegValVector.ll?rev=299915&r1=299914&r2=299915&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-05-22-NegValVector.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/2008-05-22-NegValVector.ll Tue Apr 11 00:42:47 2017
@@ -6,3 +6,9 @@ define <3 x i8> @f(<3 x i8> %a) {
ret <3 x i8> %B
}
+define <3 x i4> @g(<3 x i4> %a) {
+ %A = sub <3 x i4> zeroinitializer, %a
+ %B = mul <3 x i4> %A, <i4 5, i4 5, i4 5>
+ ret <3 x i4> %B
+}
+
Modified: llvm/trunk/test/Transforms/InstCombine/rem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/rem.ll?rev=299915&r1=299914&r2=299915&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/rem.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/rem.ll Tue Apr 11 00:42:47 2017
@@ -57,12 +57,11 @@ define i5 @biggest_divisor(i5 %x) {
ret i5 %rem
}
-; TODO: Should vector subtract of constant be canonicalized to add?
define <2 x i4> @big_divisor_vec(<2 x i4> %x) {
; CHECK-LABEL: @big_divisor_vec(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp ult <2 x i4> %x, <i4 -3, i4 -3>
-; CHECK-NEXT: [[TMP2:%.*]] = sub <2 x i4> %x, <i4 -3, i4 -3>
-; CHECK-NEXT: [[REM:%.*]] = select <2 x i1> [[TMP1]], <2 x i4> %x, <2 x i4> [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = icmp ult <2 x i4> [[X:%.*]], <i4 -3, i4 -3>
+; CHECK-NEXT: [[TMP2:%.*]] = add <2 x i4> [[X]], <i4 3, i4 3>
+; CHECK-NEXT: [[REM:%.*]] = select <2 x i1> [[TMP1]], <2 x i4> [[X]], <2 x i4> [[TMP2]]
; CHECK-NEXT: ret <2 x i4> [[REM]]
;
%rem = urem <2 x i4> %x, <i4 13, i4 13>
More information about the llvm-commits
mailing list