Skip to content

Commit fed9433

Browse files
committed
Revert "[DAG] Reducing instructions by better legalization handling of AVGFLOORU for illegal data types (#99913)"
This reverts commit d5521d1. The AArch64 test is failing on the bots.
1 parent bbc457a commit fed9433

File tree

5 files changed

+60
-329
lines changed

5 files changed

+60
-329
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9379,26 +9379,6 @@ SDValue TargetLowering::expandAVG(SDNode *N, SelectionDAG &DAG) const {
93799379
}
93809380
}
93819381

9382-
// avgflooru(lhs, rhs) -> or(lshr(add(lhs, rhs),1),shl(overflow, typesize-1))
9383-
if (Opc == ISD::AVGFLOORU && VT.isScalarInteger() && !isTypeLegal(VT)) {
9384-
SDValue UAddWithOverflow =
9385-
DAG.getNode(ISD::UADDO, dl, DAG.getVTList(VT, MVT::i1), {RHS, LHS});
9386-
9387-
SDValue Sum = UAddWithOverflow.getValue(0);
9388-
SDValue Overflow = UAddWithOverflow.getValue(1);
9389-
9390-
// Right shift the sum by 1
9391-
SDValue One = DAG.getShiftAmountConstant(1, VT, dl);
9392-
SDValue LShrVal = DAG.getNode(ISD::SRL, dl, VT, Sum, One);
9393-
9394-
SDValue ZeroExtOverflow = DAG.getNode(ISD::ANY_EXTEND, dl, VT, Overflow);
9395-
SDValue OverflowShl =
9396-
DAG.getNode(ISD::SHL, dl, VT, ZeroExtOverflow,
9397-
DAG.getConstant(VT.getScalarSizeInBits() - 1, dl, VT));
9398-
9399-
return DAG.getNode(ISD::OR, dl, VT, LShrVal, OverflowShl);
9400-
}
9401-
94029382
// avgceils(lhs, rhs) -> sub(or(lhs,rhs),ashr(xor(lhs,rhs),1))
94039383
// avgceilu(lhs, rhs) -> sub(or(lhs,rhs),lshr(xor(lhs,rhs),1))
94049384
// avgfloors(lhs, rhs) -> add(and(lhs,rhs),ashr(xor(lhs,rhs),1))

llvm/test/CodeGen/AArch64/avgflooru-i128.ll

Lines changed: 0 additions & 124 deletions
This file was deleted.

llvm/test/CodeGen/RISCV/avgflooru.ll

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,18 @@ define i32 @test_ext_i32(i32 %a0, i32 %a1) nounwind {
164164
define i64 @test_fixed_i64(i64 %a0, i64 %a1) nounwind {
165165
; RV32I-LABEL: test_fixed_i64:
166166
; RV32I: # %bb.0:
167-
; RV32I-NEXT: add a4, a3, a1
168-
; RV32I-NEXT: add a0, a2, a0
169-
; RV32I-NEXT: sltu a1, a0, a2
170-
; RV32I-NEXT: add a2, a4, a1
171-
; RV32I-NEXT: beq a2, a3, .LBB6_2
172-
; RV32I-NEXT: # %bb.1:
173-
; RV32I-NEXT: sltu a1, a2, a3
174-
; RV32I-NEXT: .LBB6_2:
167+
; RV32I-NEXT: and a4, a1, a3
168+
; RV32I-NEXT: xor a1, a1, a3
169+
; RV32I-NEXT: srli a3, a1, 1
170+
; RV32I-NEXT: add a3, a4, a3
175171
; RV32I-NEXT: slli a1, a1, 31
176-
; RV32I-NEXT: srli a3, a2, 1
177-
; RV32I-NEXT: or a1, a3, a1
178-
; RV32I-NEXT: slli a2, a2, 31
179-
; RV32I-NEXT: srli a0, a0, 1
180-
; RV32I-NEXT: or a0, a0, a2
172+
; RV32I-NEXT: xor a4, a0, a2
173+
; RV32I-NEXT: srli a4, a4, 1
174+
; RV32I-NEXT: or a1, a4, a1
175+
; RV32I-NEXT: and a2, a0, a2
176+
; RV32I-NEXT: add a0, a2, a1
177+
; RV32I-NEXT: sltu a1, a0, a2
178+
; RV32I-NEXT: add a1, a3, a1
181179
; RV32I-NEXT: ret
182180
;
183181
; RV64I-LABEL: test_fixed_i64:
@@ -197,20 +195,18 @@ define i64 @test_fixed_i64(i64 %a0, i64 %a1) nounwind {
197195
define i64 @test_ext_i64(i64 %a0, i64 %a1) nounwind {
198196
; RV32I-LABEL: test_ext_i64:
199197
; RV32I: # %bb.0:
200-
; RV32I-NEXT: add a4, a3, a1
201-
; RV32I-NEXT: add a0, a2, a0
202-
; RV32I-NEXT: sltu a1, a0, a2
203-
; RV32I-NEXT: add a2, a4, a1
204-
; RV32I-NEXT: beq a2, a3, .LBB7_2
205-
; RV32I-NEXT: # %bb.1:
206-
; RV32I-NEXT: sltu a1, a2, a3
207-
; RV32I-NEXT: .LBB7_2:
198+
; RV32I-NEXT: and a4, a1, a3
199+
; RV32I-NEXT: xor a1, a1, a3
200+
; RV32I-NEXT: srli a3, a1, 1
201+
; RV32I-NEXT: add a3, a4, a3
208202
; RV32I-NEXT: slli a1, a1, 31
209-
; RV32I-NEXT: srli a3, a2, 1
210-
; RV32I-NEXT: or a1, a3, a1
211-
; RV32I-NEXT: slli a2, a2, 31
212-
; RV32I-NEXT: srli a0, a0, 1
213-
; RV32I-NEXT: or a0, a0, a2
203+
; RV32I-NEXT: xor a4, a0, a2
204+
; RV32I-NEXT: srli a4, a4, 1
205+
; RV32I-NEXT: or a1, a4, a1
206+
; RV32I-NEXT: and a2, a0, a2
207+
; RV32I-NEXT: add a0, a2, a1
208+
; RV32I-NEXT: sltu a1, a0, a2
209+
; RV32I-NEXT: add a1, a3, a1
214210
; RV32I-NEXT: ret
215211
;
216212
; RV64I-LABEL: test_ext_i64:

llvm/test/CodeGen/X86/avgflooru-i128.ll

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)