[X86] Disable load folding for X86ISD::ADD with 128 as an immediate.

It can be turned into a sub with -128 instead as long as the
carry flag isn't used.
This commit is contained in:
Craig Topper 2020-02-16 20:52:18 -08:00
parent c7fa409bca
commit dd0b18e1ec
2 changed files with 7 additions and 2 deletions

View File

@ -643,6 +643,11 @@ X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const {
if ((U->getOpcode() == ISD::ADD || U->getOpcode() == ISD::SUB) &&
(-Imm->getAPIntValue()).isSignedIntN(8))
return false;
if ((U->getOpcode() == X86ISD::ADD || U->getOpcode() == X86ISD::SUB) &&
(-Imm->getAPIntValue()).isSignedIntN(8) &&
hasNoCarryFlagUses(SDValue(U, 1)))
return false;
}
// If the other operand is a TLS address, we should fold it instead.

View File

@ -560,8 +560,8 @@ declare void @bar_i64(i64)
define void @add_i32_128_flag(i32 %x) {
; X32-LABEL: add_i32_128_flag:
; X32: # %bb.0: # %entry
; X32-NEXT: movl $128, %eax
; X32-NEXT: addl {{[0-9]+}}(%esp), %eax
; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
; X32-NEXT: subl $-128, %eax
; X32-NEXT: je .LBB19_2
; X32-NEXT: # %bb.1: # %if.then
; X32-NEXT: pushl %eax