]> granicus.if.org Git - llvm/commitdiff
[X86] Add X86TargetLowering::isCommutativeBinOp override.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 29 Mar 2019 11:25:58 +0000 (11:25 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 29 Mar 2019 11:25:58 +0000 (11:25 +0000)
We currently just have test coverage for PMULUDQ - will add more in the future.

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

lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
test/CodeGen/X86/pmul.ll

index 50210ad78a2f814c2479750f04e6dcb42510ae3a..a5691cdfc6aa507f9aaa043640160f3bc73b884a 100644 (file)
@@ -28018,6 +28018,16 @@ bool X86TargetLowering::isVectorShiftByScalarCheap(Type *Ty) const {
   return true;
 }
 
+bool X86TargetLowering::isCommutativeBinOp(unsigned Opcode) const {
+  switch (Opcode) {
+  // TODO: Add more X86ISD opcodes once we have test coverage.
+  case X86ISD::PMULUDQ:
+    return true;
+  }
+
+  return TargetLoweringBase::isCommutativeBinOp(Opcode);
+}
+
 bool X86TargetLowering::isTruncateFree(Type *Ty1, Type *Ty2) const {
   if (!Ty1->isIntegerTy() || !Ty2->isIntegerTy())
     return false;
index e1d54e223389b0f961801739e3fa07694f08400c..0f7065b350304996d2e36d0be69fdc46ebbbe167 100644 (file)
@@ -957,6 +957,9 @@ namespace llvm {
 
     bool isVectorShiftByScalarCheap(Type *Ty) const override;
 
+    /// Returns true if the opcode is a commutative binary operation.
+    bool isCommutativeBinOp(unsigned Opcode) const override;
+
     /// Return true if it's free to truncate a value of
     /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in
     /// register EAX to i16 by referencing its sub-register AX.
index 011ca1240c93921ab574b60d2475356fe28dc5be..1960e790925a9fbdf66a98709f17ab5eb63288be 100644 (file)
@@ -1374,9 +1374,9 @@ define <2 x i64> @pmuldq_square(<2 x i64> %x) {
 ; SSE2-NEXT:    punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
 ; SSE2-NEXT:    psrlq $32, %xmm0
 ; SSE2-NEXT:    pmuludq %xmm1, %xmm0
+; SSE2-NEXT:    pmuludq %xmm1, %xmm1
 ; SSE2-NEXT:    paddq %xmm0, %xmm0
 ; SSE2-NEXT:    psllq $32, %xmm0
-; SSE2-NEXT:    pmuludq %xmm1, %xmm1
 ; SSE2-NEXT:    paddq %xmm1, %xmm0
 ; SSE2-NEXT:    retq
 ;