Skip to content

Commit ef87d43

Browse files
committed
Revert rGa8cef6b58e2d41f04ed4fa63c3f628eac1a28925 "[X86] promoteExtBeforeAdd - add support for or/xor 'addlike' patterns"
Investigating reports of issues with second stage clang builds
1 parent 8b13775 commit ef87d43

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52131,12 +52131,11 @@ static SDValue combineSignExtendInReg(SDNode *N, SelectionDAG &DAG,
5213152131
return SDValue();
5213252132
}
5213352133

52134-
/// sext(add_nsw(x, C)) --> add_nsw(sext(x), C_sext)
52135-
/// zext(add_nuw(x, C)) --> add_nuw(zext(x), C_zext)
52136-
/// zext(addlike(x, C)) --> add(zext(x), C_zext)
52137-
/// Promoting a sign/zero extension ahead of a no overflow 'add' or 'addlike'
52138-
/// exposes opportunities to combine math ops, use an LEA, or use a complex
52139-
/// addressing mode. This can eliminate extend, add, and shift instructions.
52134+
/// sext(add_nsw(x, C)) --> add(sext(x), C_sext)
52135+
/// zext(add_nuw(x, C)) --> add(zext(x), C_zext)
52136+
/// Promoting a sign/zero extension ahead of a no overflow 'add' exposes
52137+
/// opportunities to combine math ops, use an LEA, or use a complex addressing
52138+
/// mode. This can eliminate extend, add, and shift instructions.
5214052139
static SDValue promoteExtBeforeAdd(SDNode *Ext, SelectionDAG &DAG,
5214152140
const X86Subtarget &Subtarget) {
5214252141
if (Ext->getOpcode() != ISD::SIGN_EXTEND &&
@@ -52148,19 +52147,17 @@ static SDValue promoteExtBeforeAdd(SDNode *Ext, SelectionDAG &DAG,
5214852147
if (VT != MVT::i64)
5214952148
return SDValue();
5215052149

52151-
bool NSW = false, NUW = false;
52150+
SDValue Add = Ext->getOperand(0);
52151+
if (Add.getOpcode() != ISD::ADD)
52152+
return SDValue();
52153+
5215252154
bool Sext = Ext->getOpcode() == ISD::SIGN_EXTEND;
52155+
bool NSW = Add->getFlags().hasNoSignedWrap();
52156+
bool NUW = Add->getFlags().hasNoUnsignedWrap();
5215352157

52154-
SDValue Add = Ext->getOperand(0);
52155-
unsigned AddOpc = Add->getOpcode();
52156-
if (AddOpc == ISD::ADD) {
52157-
NSW = Add->getFlags().hasNoSignedWrap();
52158-
NUW = Add->getFlags().hasNoUnsignedWrap();
52159-
// We need an 'add nsw' feeding into the 'sext' or 'add nuw' feeding
52160-
// into the 'zext'
52161-
if ((Sext && !NSW) || (!Sext && !NUW))
52162-
return SDValue();
52163-
} else if (!(!Sext && DAG.isADDLike(Add)))
52158+
// We need an 'add nsw' feeding into the 'sext' or 'add nuw' feeding
52159+
// into the 'zext'
52160+
if ((Sext && !NSW) || (!Sext && !NUW))
5216452161
return SDValue();
5216552162

5216652163
// Having a constant operand to the 'add' ensures that we are not increasing
@@ -52196,7 +52193,7 @@ static SDValue promoteExtBeforeAdd(SDNode *Ext, SelectionDAG &DAG,
5219652193
SDNodeFlags Flags;
5219752194
Flags.setNoSignedWrap(NSW);
5219852195
Flags.setNoUnsignedWrap(NUW);
52199-
return DAG.getNode(AddOpc, SDLoc(Add), VT, NewExt, NewConstant, Flags);
52196+
return DAG.getNode(ISD::ADD, SDLoc(Add), VT, NewExt, NewConstant, Flags);
5220052197
}
5220152198

5220252199
// If we face {ANY,SIGN,ZERO}_EXTEND that is applied to a CMOV with constant

llvm/test/CodeGen/X86/lea-2.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define i32 @test1(i32 %A, i32 %B) {
2626
ret i32 %t4
2727
}
2828

29-
; The addlike OR instruction should fold into the LEA.
29+
; TODO: The addlike OR instruction should fold into the LEA.
3030

3131
define i64 @test2(i32 %a0, i64 %a1) {
3232
; X32-LABEL: test2:
@@ -44,7 +44,8 @@ define i64 @test2(i32 %a0, i64 %a1) {
4444
; X64: # %bb.0:
4545
; X64-NEXT: # kill: def $edi killed $edi def $rdi
4646
; X64-NEXT: andl $-8, %edi
47-
; X64-NEXT: leaq 4(%rsi,%rdi,2), %rax
47+
; X64-NEXT: orl $2, %edi
48+
; X64-NEXT: leaq (%rsi,%rdi,2), %rax
4849
; X64-NEXT: retq
4950
%x1 = and i32 %a0, -8
5051
%x2 = or i32 %x1, 2

llvm/test/CodeGen/X86/select_const.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ define i64 @select_pow2_diff_neg_invert(i1 zeroext %cond) {
626626
;
627627
; X64-LABEL: select_pow2_diff_neg_invert:
628628
; X64: # %bb.0:
629-
; X64-NEXT: movl %edi, %eax
630-
; X64-NEXT: xorq $1, %rax
629+
; X64-NEXT: xorb $1, %dil
630+
; X64-NEXT: movzbl %dil, %eax
631631
; X64-NEXT: shlq $7, %rax
632632
; X64-NEXT: addq $-99, %rax
633633
; X64-NEXT: retq

0 commit comments

Comments
 (0)