Integer legalization: fix MUL expansion

Summary:
This fixes the runtime results produces by the fallback multiplication expansion introduced in r270720.

For tests I created a fuzz tester that compares the results with Boost.Multiprecision.

Reviewers: hfinkel

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D26628

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286998 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Pawel Bylica 2016-11-15 18:29:24 +00:00
parent 34888b1f1a
commit 93f763c0e2
4 changed files with 6144 additions and 5622 deletions

View File

@ -2230,7 +2230,7 @@ void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N,
SDValue RLH = DAG.getNode(ISD::SRL, dl, NVT, RL, Shift);
SDValue U = DAG.getNode(ISD::ADD, dl, NVT,
DAG.getNode(ISD::MUL, dl, NVT, LLH, RLL), TL);
DAG.getNode(ISD::MUL, dl, NVT, LLH, RLL), TH);
SDValue UL = DAG.getNode(ISD::AND, dl, NVT, U, Mask);
SDValue UH = DAG.getNode(ISD::SRL, dl, NVT, U, Shift);
@ -2239,9 +2239,9 @@ void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N,
SDValue VH = DAG.getNode(ISD::SRL, dl, NVT, V, Shift);
SDValue W = DAG.getNode(ISD::ADD, dl, NVT,
DAG.getNode(ISD::MUL, dl, NVT, LL, RL),
DAG.getNode(ISD::MUL, dl, NVT, LLH, RLH),
DAG.getNode(ISD::ADD, dl, NVT, UH, VH));
Lo = DAG.getNode(ISD::ADD, dl, NVT, TH,
Lo = DAG.getNode(ISD::ADD, dl, NVT, TL,
DAG.getNode(ISD::SHL, dl, NVT, V, Shift));
Hi = DAG.getNode(ISD::ADD, dl, NVT, W,

File diff suppressed because it is too large Load Diff

View File

@ -15,12 +15,17 @@ entry:
; There is a lot of inter-register motion, and so matching the instruction
; sequence will be fragile. There should be 6 underlying multiplications.
; CHECK: imulq
; CHECK: mulq
; CHECK: imulq
; CHECK: imulq
; CHECK: mulq
; CHECK: imulq
; CHECK: imulq
; CHECK: imulq
; CHECK: mulq
; CHECK: mulq
; CHECK: mulq
; CHECK: mulq
; CHECK-NOT: imulq
; CHECK-NOT: mulq
; CHECK: retq
attributes #0 = { norecurse nounwind uwtable "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" }

File diff suppressed because it is too large Load Diff