]> granicus.if.org Git - llvm/commitdiff
[X86] Don't use CombineTo to skip adding new nodes to the DAGCombiner worklist in...
authorCraig Topper <craig.topper@intel.com>
Thu, 26 Jul 2018 05:40:10 +0000 (05:40 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 26 Jul 2018 05:40:10 +0000 (05:40 +0000)
I'm not sure if this was trying to avoid optimizing the new nodes further or what. Or maybe to prevent a cycle if something tried to reform the multiply? But I don't think its a reliable way to do that. If the user of the expanded multiply is visited by the DAGCombiner after this conversion happens, the DAGCombiner will check its operands, see that they haven't been visited by the DAGCombiner before and it will then add the first node to the worklist. This process will repeat until all the new nodes are visited.

So this seems like an unreliable prevention at best. So this patch just returns the new nodes like any other combine. If this starts causing problems we can try to add target specific nodes or something to more directly prevent optimizations.

Now that we handle the combine normally, we can combine any negates the mul expansion creates into their users since those will be visited now.

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

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/mul-constant-i32.ll

index 48093b413c8d934a7f75f664d446611885fc2ea1..c53c8d160a20221d9d414d432c57c56eafdc70e0 100644 (file)
@@ -33970,11 +33970,7 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
     }
   }
 
-  if (NewMul)
-    // Do not add new nodes to DAG combiner worklist.
-    return DCI.CombineTo(N, NewMul, false);
-
-  return SDValue();
+  return NewMul;
 }
 
 static SDValue combineShiftLeft(SDNode *N, SelectionDAG &DAG) {
index 79b13a208cb3b06bf5de4e90408c998492a2410e..356d5a00abf6518f03be627631fe5459be6e8e6e 100644 (file)
@@ -2081,25 +2081,25 @@ define i32 @mul_neg_fold(i32 %a, i32 %b) {
 ; X86-LABEL: mul_neg_fold:
 ; X86:       # %bb.0:
 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT:    leal (%eax,%eax,8), %eax
-; X86-NEXT:    negl %eax
-; X86-NEXT:    addl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    leal (%ecx,%ecx,8), %ecx
+; X86-NEXT:    subl %ecx, %eax
 ; X86-NEXT:    retl
 ;
 ; X64-HSW-LABEL: mul_neg_fold:
 ; X64-HSW:       # %bb.0:
 ; X64-HSW-NEXT:    # kill: def $edi killed $edi def $rdi
 ; X64-HSW-NEXT:    leal (%rdi,%rdi,8), %eax # sched: [1:0.50]
-; X64-HSW-NEXT:    negl %eax # sched: [1:0.25]
-; X64-HSW-NEXT:    addl %esi, %eax # sched: [1:0.25]
+; X64-HSW-NEXT:    subl %eax, %esi # sched: [1:0.25]
+; X64-HSW-NEXT:    movl %esi, %eax # sched: [1:0.25]
 ; X64-HSW-NEXT:    retq # sched: [7:1.00]
 ;
 ; X64-JAG-LABEL: mul_neg_fold:
 ; X64-JAG:       # %bb.0:
 ; X64-JAG-NEXT:    # kill: def $edi killed $edi def $rdi
 ; X64-JAG-NEXT:    leal (%rdi,%rdi,8), %eax # sched: [2:1.00]
-; X64-JAG-NEXT:    negl %eax # sched: [1:0.50]
-; X64-JAG-NEXT:    addl %esi, %eax # sched: [1:0.50]
+; X64-JAG-NEXT:    subl %eax, %esi # sched: [1:0.50]
+; X64-JAG-NEXT:    movl %esi, %eax # sched: [1:0.50]
 ; X64-JAG-NEXT:    retq # sched: [4:1.00]
 ;
 ; X86-NOOPT-LABEL: mul_neg_fold:
@@ -2124,8 +2124,8 @@ define i32 @mul_neg_fold(i32 %a, i32 %b) {
 ; X64-SLM:       # %bb.0:
 ; X64-SLM-NEXT:    # kill: def $edi killed $edi def $rdi
 ; X64-SLM-NEXT:    leal (%rdi,%rdi,8), %eax # sched: [1:1.00]
-; X64-SLM-NEXT:    negl %eax # sched: [1:0.50]
-; X64-SLM-NEXT:    addl %esi, %eax # sched: [1:0.50]
+; X64-SLM-NEXT:    subl %eax, %esi # sched: [1:0.50]
+; X64-SLM-NEXT:    movl %esi, %eax # sched: [1:0.50]
 ; X64-SLM-NEXT:    retq # sched: [4:1.00]
 ;
 ; SLM-NOOPT-LABEL: mul_neg_fold: