llvm.org GIT mirror llvm / 3aa994c
[X86] Fold X86ISD::SBB(ISD::SUB(X,Y),0) -> X86ISD::SBB(X,Y) (PR25858) We often generate X86ISD::SBB(X, 0) for carry flag arithmetic. I had tried to create test cases for the ADC equivalent (which often uses the same pattern) but haven't managed to find anything yet. Differential Revision: https://reviews.llvm.org/D57169 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352288 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 1 year, 23 days ago
2 changed file(s) with 15 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
4056540565 Flags);
4056640566 }
4056740567
40568 // Fold SBB(SUB(X,Y),0,Carry) -> SBB(X,Y,Carry)
40569 // iff the flag result is dead.
40570 SDValue Op0 = N->getOperand(0);
40571 SDValue Op1 = N->getOperand(1);
40572 if (Op0.getOpcode() == ISD::SUB && isNullConstant(Op1) &&
40573 !N->hasAnyUseOfValue(1))
40574 return DAG.getNode(X86ISD::SBB, SDLoc(N), N->getVTList(), Op0.getOperand(0),
40575 Op0.getOperand(1), N->getOperand(2));
40576
4056840577 return SDValue();
4056940578 }
4057040579
1212 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1313 ; X86-NEXT: movl (%ecx), %esi
1414 ; X86-NEXT: movl 4(%ecx), %ecx
15 ; X86-NEXT: subl 4(%edx), %ecx
1615 ; X86-NEXT: subl (%edx), %esi
17 ; X86-NEXT: sbbl $0, %ecx
16 ; X86-NEXT: sbbl 4(%edx), %ecx
17 ; X86-NEXT: movl %ecx, 4(%eax)
1818 ; X86-NEXT: movl %esi, (%eax)
19 ; X86-NEXT: movl %ecx, 4(%eax)
2019 ; X86-NEXT: popl %esi
2120 ; X86-NEXT: retl $4
2221 ;
2524 ; X64-NEXT: movq %rdi, %rax
2625 ; X64-NEXT: movl (%rsi), %ecx
2726 ; X64-NEXT: movl 4(%rsi), %esi
28 ; X64-NEXT: subl 4(%rdx), %esi
2927 ; X64-NEXT: subl (%rdx), %ecx
30 ; X64-NEXT: sbbl $0, %esi
28 ; X64-NEXT: sbbl 4(%rdx), %esi
29 ; X64-NEXT: movl %esi, 4(%rdi)
3130 ; X64-NEXT: movl %ecx, (%rdi)
32 ; X64-NEXT: movl %esi, 4(%rdi)
3331 ; X64-NEXT: retq
3432 top:
3533 %3 = bitcast %WideUInt32* %1 to i32*
9391 ; X64-NEXT: movq %rdi, %rax
9492 ; X64-NEXT: movq (%rsi), %rcx
9593 ; X64-NEXT: movq 8(%rsi), %rsi
96 ; X64-NEXT: subq 8(%rdx), %rsi
9794 ; X64-NEXT: subq (%rdx), %rcx
98 ; X64-NEXT: sbbq $0, %rsi
95 ; X64-NEXT: sbbq 8(%rdx), %rsi
96 ; X64-NEXT: movq %rsi, 8(%rdi)
9997 ; X64-NEXT: movq %rcx, (%rdi)
100 ; X64-NEXT: movq %rsi, 8(%rdi)
10198 ; X64-NEXT: retq
10299 top:
103100 %3 = bitcast %WideUInt64* %1 to i64*