[x86] Revert r214007: Fix PR20355 ...
authorChandler Carruth <chandlerc@gmail.com>
Sat, 26 Jul 2014 02:14:54 +0000 (02:14 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 26 Jul 2014 02:14:54 +0000 (02:14 +0000)
The clever way to implement signed multiplication with unsigned *is
already implemented* and tested and working correctly. The bug is
somewhere else. Re-investigating.

This will teach me to not scroll far enough to read the code that did
what I thought needed to be done.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214009 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/pmul.ll
test/CodeGen/X86/vector-idiv.ll

index c961d229a4137e2c568730961a45d2c8f00bd9a2..ce06eb9cdebbc05cf0e90a084599f0c95309810c 100644 (file)
@@ -970,6 +970,7 @@ void X86TargetLowering::resetOperationActions() {
     setOperationAction(ISD::MUL,                MVT::v4i32, Custom);
     setOperationAction(ISD::MUL,                MVT::v2i64, Custom);
     setOperationAction(ISD::UMUL_LOHI,          MVT::v4i32, Custom);
+    setOperationAction(ISD::SMUL_LOHI,          MVT::v4i32, Custom);
     setOperationAction(ISD::MULHU,              MVT::v8i16, Legal);
     setOperationAction(ISD::MULHS,              MVT::v8i16, Legal);
     setOperationAction(ISD::SUB,                MVT::v16i8, Legal);
@@ -1112,8 +1113,6 @@ void X86TargetLowering::resetOperationActions() {
     // FIXME: Do we need to handle scalar-to-vector here?
     setOperationAction(ISD::MUL,                MVT::v4i32, Legal);
 
-    setOperationAction(ISD::SMUL_LOHI,          MVT::v4i32, Custom);
-
     setOperationAction(ISD::VSELECT,            MVT::v2f64, Custom);
     setOperationAction(ISD::VSELECT,            MVT::v2i64, Custom);
     setOperationAction(ISD::VSELECT,            MVT::v4i32, Custom);
@@ -15433,9 +15432,8 @@ static SDValue LowerMUL_LOHI(SDValue Op, const X86Subtarget *Subtarget,
   // ints.
   MVT MulVT = VT == MVT::v4i32 ? MVT::v2i64 : MVT::v4i64;
   bool IsSigned = Op->getOpcode() == ISD::SMUL_LOHI;
-  assert((!IsSigned || Subtarget->hasSSE41()) &&
-         "We need PMULDQ for signed multiplies!");
-  unsigned Opcode = IsSigned ? X86ISD::PMULDQ : X86ISD::PMULUDQ;
+  unsigned Opcode =
+      (!IsSigned || !Subtarget->hasSSE41()) ? X86ISD::PMULUDQ : X86ISD::PMULDQ;
   // PMULUDQ <4 x i32> <a|b|c|d>, <4 x i32> <e|f|g|h>
   // => <2 x i64> <ae|cg>
   SDValue Mul1 = DAG.getNode(ISD::BITCAST, dl, VT,
index e129d5618aa2f00dbd421955eec0c0c2e2ffd0c3..4944d6b9083e89443cd4fe1259434e4b856c8f21 100644 (file)
@@ -84,10 +84,10 @@ entry:
 }
 
 define <2 x i64> @f(<2 x i64> %i, <2 x i64> %j) nounwind  {
-; ALL-LABEL: f:
-; ALL:         pmuludq
-; ALL:         pmuludq
-; ALL:         pmuludq
+; CHECK-LABEL: f:
+; CHECK:         pmuludq
+; CHECK:         pmuludq
+; CHECK:         pmuludq
 entry:
   ; Use a call to force spills.
   call void @foo()
index 0214a47f44cf3aa7a5a0234c8d56846f091b2ea4..ec1ce3da5e14c92d5df26590d5b0a37ef0c77171 100644 (file)
@@ -131,12 +131,18 @@ define <4 x i32> @test8(<4 x i32> %a) {
 ; SSE41: psrad $2
 ; SSE41: padd
 
-; FIXME: scalarized -- there is no signed multiply in SSE.
 ; SSE-LABEL: test8:
-; SSE: imulq
-; SSE: imulq
-; SSE: imulq
-; SSE: imulq
+; SSE: pmuludq
+; SSE: pshufd  $49
+; SSE: pshufd  $49
+; SSE: pmuludq
+; SSE: shufps  $-35
+; SSE: pshufd  $-40
+; SSE: psubd
+; SSE: padd
+; SSE: psrld $31
+; SSE: psrad $2
+; SSE: padd
 
 ; AVX-LABEL: test8:
 ; AVX: vpmuldq