Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit ad84cf4

Browse files
committed
Revert "[ARM] Lower UDIV+UREM to UDIV+MLS (and the same for SREM)"
This reverts commit r280808. It is possible that this change results in an infinite loop. This is causing timeouts in some tests on ARM, and a Chromebook bot is failing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280918 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 09e9256 commit ad84cf4

File tree

2 files changed

+1
-61
lines changed

2 files changed

+1
-61
lines changed

lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12098,24 +12098,6 @@ SDValue ARMTargetLowering::LowerDivRem(SDValue Op, SelectionDAG &DAG) const {
1209812098
bool isSigned = (Opcode == ISD::SDIVREM);
1209912099
EVT VT = Op->getValueType(0);
1210012100
Type *Ty = VT.getTypeForEVT(*DAG.getContext());
12101-
SDLoc dl(Op);
12102-
12103-
// If the target has hardware divide, use divide + multiply + subtract:
12104-
// div = a / b
12105-
// rem = a - b * div
12106-
// return {div, rem}
12107-
// This should be lowered into UDIV/SDIV + MLS later on.
12108-
if (Subtarget->hasDivide()) {
12109-
unsigned DivOpcode = isSigned ? ISD::SDIV : ISD::UDIV;
12110-
const SDValue Dividend = Op->getOperand(0);
12111-
const SDValue Divisor = Op->getOperand(1);
12112-
SDValue Div = DAG.getNode(DivOpcode, dl, VT, Dividend, Divisor);
12113-
SDValue Mul = DAG.getNode(ISD::MUL, dl, VT, Div, Divisor);
12114-
SDValue Rem = DAG.getNode(ISD::SUB, dl, VT, Dividend, Mul);
12115-
12116-
SDValue Values[2] = {Div, Rem};
12117-
return DAG.getNode(ISD::MERGE_VALUES, dl, DAG.getVTList(VT, VT), Values);
12118-
}
1211912101

1212012102
RTLIB::Libcall LC = getDivRemLibcall(Op.getNode(),
1212112103
VT.getSimpleVT().SimpleTy);
@@ -12129,6 +12111,7 @@ SDValue ARMTargetLowering::LowerDivRem(SDValue Op, SelectionDAG &DAG) const {
1212912111

1213012112
Type *RetTy = (Type*)StructType::get(Ty, Ty, nullptr);
1213112113

12114+
SDLoc dl(Op);
1213212115
TargetLowering::CallLoweringInfo CLI(DAG);
1213312116
CLI.setDebugLoc(dl).setChain(InChain)
1213412117
.setCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args))

test/CodeGen/ARM/urem-opt-size.ll

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
; expanded to a sequence of umull, lsrs, muls and sub instructions, but
44
; just a call to __aeabi_uidivmod.
55
;
6-
; When the processor features hardware division, UDIV + UREM can be turned
7-
; into UDIV + MLS. This prevents the library function __aeabi_uidivmod to be
8-
; pulled into the binary. The test uses ARMv7-M.
9-
;
106
; RUN: llc -mtriple=armv7a-eabi -mattr=-neon -verify-machineinstrs %s -o - | FileCheck %s
11-
; RUN: llc -mtriple=thumbv7m-eabi -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=V7M
127

138
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
149
target triple = "thumbv7m-arm-none-eabi"
@@ -33,56 +28,18 @@ entry:
3328
ret i32 %div
3429
}
3530

36-
; Test for unsigned remainder
3731
define i32 @foo3() local_unnamed_addr #0 {
3832
entry:
3933
; CHECK-LABEL: foo3:
4034
; CHECK: __aeabi_uidivmod
4135
; CHECK-NOT: umull
42-
; V7M-LABEL: foo3:
43-
; V7M: udiv [[R2:r[0-9]+]], [[R0:r[0-9]+]], [[R1:r[0-9]+]]
44-
; V7M: mls {{r[0-9]+}}, [[R2]], [[R1]], [[R0]]
45-
; V7M-NOT: __aeabi_uidivmod
4636
%call = tail call i32 bitcast (i32 (...)* @GetValue to i32 ()*)()
4737
%rem = urem i32 %call, 1000000
4838
%cmp = icmp eq i32 %rem, 0
4939
%conv = zext i1 %cmp to i32
5040
ret i32 %conv
5141
}
5242

53-
; Test for signed remainder
54-
define i32 @foo4() local_unnamed_addr #0 {
55-
entry:
56-
; CHECK-LABEL: foo4:
57-
; CHECK:__aeabi_idivmod
58-
; V7M-LABEL: foo4:
59-
; V7M: sdiv [[R2:r[0-9]+]], [[R0:r[0-9]+]], [[R1:r[0-9]+]]
60-
; V7M: mls {{r[0-9]+}}, [[R2]], [[R1]], [[R0]]
61-
; V7M-NOT: __aeabi_idivmod
62-
%call = tail call i32 bitcast (i32 (...)* @GetValue to i32 ()*)()
63-
%rem = srem i32 %call, 1000000
64-
ret i32 %rem
65-
}
66-
67-
; Check that doing a sdiv+srem has the same effect as only the srem,
68-
; as the division needs to be computed anyway in order to calculate
69-
; the remainder (i.e. make sure we don't end up with two divisions).
70-
define i32 @foo5() local_unnamed_addr #0 {
71-
entry:
72-
; CHECK-LABEL: foo5:
73-
; CHECK:__aeabi_idivmod
74-
; V7M-LABEL: foo5:
75-
; V7M: sdiv [[R2:r[0-9]+]], [[R0:r[0-9]+]], [[R1:r[0-9]+]]
76-
; V7M-NOT: sdiv
77-
; V7M: mls {{r[0-9]+}}, [[R2]], [[R1]], [[R0]]
78-
; V7M-NOT: __aeabi_idivmod
79-
%call = tail call i32 bitcast (i32 (...)* @GetValue to i32 ()*)()
80-
%div = sdiv i32 %call, 1000000
81-
%rem = srem i32 %call, 1000000
82-
%add = add i32 %div, %rem
83-
ret i32 %add
84-
}
85-
8643
declare i32 @GetValue(...) local_unnamed_addr
8744

8845
attributes #0 = { minsize nounwind optsize }

0 commit comments

Comments
 (0)