[X86] Allow i16 subtracts to be promoted if the load is on the LHS and its not being...
authorCraig Topper <craig.topper@intel.com>
Sun, 1 Apr 2018 06:29:25 +0000 (06:29 +0000)
committerCraig Topper <craig.topper@intel.com>
Sun, 1 Apr 2018 06:29:25 +0000 (06:29 +0000)
llvm-svn: 328928

llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/promote-i16.ll

index 5ee9ff8..c39be22 100644 (file)
@@ -38742,12 +38742,12 @@ bool X86TargetLowering::IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const {
   case ISD::SUB: {
     SDValue N0 = Op.getOperand(0);
     SDValue N1 = Op.getOperand(1);
-    if (!Commute && MayFoldLoad(N1))
-      return false;
     // Avoid disabling potential load folding opportunities.
-    if (MayFoldLoad(N0) && (!isa<ConstantSDNode>(N1) || MayFoldIntoStore(Op)))
+    if (MayFoldLoad(N1) &&
+        (!Commute || !isa<ConstantSDNode>(N0) || MayFoldIntoStore(Op)))
       return false;
-    if (MayFoldLoad(N1) && (!isa<ConstantSDNode>(N0) || MayFoldIntoStore(Op)))
+    if (MayFoldLoad(N0) &&
+        ((Commute && !isa<ConstantSDNode>(N1)) || MayFoldIntoStore(Op)))
       return false;
   }
   }
index cc60786..b0559f5 100644 (file)
@@ -49,7 +49,8 @@ define signext i16 @baz(i16* %x, i16 signext %y) nounwind {
 ; X64-LABEL: baz:
 ; X64:       # %bb.0: # %entry
 ; X64-NEXT:    movzwl (%rdi), %eax
-; X64-NEXT:    subw %si, %ax
+; X64-NEXT:    subl %esi, %eax
+; X64-NEXT:    # kill: def $ax killed $ax killed $eax
 ; X64-NEXT:    retq
 entry:
   %0 = load i16, i16* %x