diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -2431,6 +2431,15 @@ return false; break; + case ISD::XOR: + // We want to look through a transform in InstCombine that + // turns 'add' with min_signed_val into 'xor', so we can treat this 'xor' + // exactly like an 'add'. + if (auto *NC1 = dyn_cast(N.getOperand(1))) + if (NC1->isMinSignedValue() && !matchAdd(N, AM, Depth)) + return false; + break; + case ISD::AND: { // Perform some heroic transforms on an and of a constant-count shift // with a constant to enable use of the scaled offset field. diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -840,11 +840,11 @@ // Define X86-specific addressing mode. def addr : ComplexPattern; def lea32addr : ComplexPattern; // In 64-bit mode 32-bit LEAs can use RIP-relative addressing. def lea64_32addr : ComplexPattern; @@ -855,7 +855,7 @@ [tglobaltlsaddr], []>; def lea64addr : ComplexPattern; def tls64addr : ComplexPattern