[x86] Fix crashes in lowering bitcast instructions with the widening

mode.

This also runs the test in that mode which would reproduce the crash.
What I love is that *every single FIXME* in the test is addressed by
switching to widening.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212254 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2014-07-03 03:43:47 +00:00
parent c179202bb4
commit 7e924a68b5
2 changed files with 67 additions and 8 deletions

View File

@ -16410,6 +16410,13 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
MVT::v2f64, N->getOperand(0));
SDValue ToVecInt = DAG.getNode(ISD::BITCAST, dl, WiderVT, Expanded);
if (ExperimentalVectorWideningLegalization) {
// If we are legalizing vectors by widening, we already have the desired
// legal vector type, just return it.
Results.push_back(ToVecInt);
return;
}
SmallVector<SDValue, 8> Elts;
for (unsigned i = 0, e = NumElts; i != e; ++i)
Elts.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, SVT,

View File

@ -1,4 +1,5 @@
; RUN: llc < %s -march=x86-64 -mcpu=core2 -mattr=+sse2 | FileCheck %s
; RUN: llc < %s -march=x86-64 -mcpu=core2 -mattr=+sse2 -x86-experimental-vector-widening-legalization | FileCheck %s --check-prefix=CHECK-WIDE
define double @test1(double %A) {
@ -9,14 +10,19 @@ define double @test1(double %A) {
}
; FIXME: Ideally we should be able to fold the entire body of @test1 into a
; single paddd instruction. At the moment we produce the sequence
; pshufd+paddq+pshufd.
; pshufd+paddq+pshufd. This is fixed with the widening legalization.
;
; CHECK-LABEL: test1
; CHECK-NOT: movsd
; CHECK: pshufd
; CHECK-NEXT: paddd
; CHECK-NEXT: pshufd
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test1
; CHECK-WIDE-NOT: movsd
; CHECK-WIDE: paddd
; CHECK-WIDE-NEXT: ret
define double @test2(double %A, double %B) {
@ -30,6 +36,11 @@ define double @test2(double %A, double %B) {
; CHECK-NOT: movsd
; CHECK: paddd
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test2
; CHECK-WIDE-NOT: movsd
; CHECK-WIDE: paddd
; CHECK-WIDE-NEXT: ret
define i64 @test3(i64 %A) {
@ -43,6 +54,12 @@ define i64 @test3(i64 %A) {
; CHECK: addps
; CHECK-NOT: pshufd
; CHECK: ret
;
; CHECK-WIDE-LABEL: test3
; CHECK-WIDE-NOT: pshufd
; CHECK-WIDE: addps
; CHECK-WIDE-NOT: pshufd
; CHECK-WIDE: ret
define i64 @test4(i64 %A) {
@ -52,13 +69,20 @@ define i64 @test4(i64 %A) {
ret i64 %2
}
; FIXME: At the moment we still produce the sequence pshufd+paddq+pshufd.
; Ideally, we should fold that sequence into a single paddd.
; Ideally, we should fold that sequence into a single paddd. This is fixed with
; the widening legalization.
;
; CHECK-LABEL: test4
; CHECK: pshufd
; CHECK-NEXT: paddq
; CHECK-NEXT: pshufd
; CHECK: ret
;
; CHECK-WIDE-LABEL: test4
; CHECK-WIDE: movd %rdi,
; CHECK-WIDE-NEXT: paddd
; CHECK-WIDE-NEXT: movd {{.*}}, %rax
; CHECK-WIDE: ret
define double @test5(double %A) {
@ -70,6 +94,10 @@ define double @test5(double %A) {
; CHECK-LABEL: test5
; CHECK: addps
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test5
; CHECK-WIDE: addps
; CHECK-WIDE-NEXT: ret
define double @test6(double %A) {
@ -79,14 +107,20 @@ define double @test6(double %A) {
ret double %2
}
; FIXME: Ideally we should be able to fold the entire body of @test6 into a
; single paddw instruction.
; single paddw instruction. This is fixed with the widening legalization.
;
; CHECK-LABEL: test6
; CHECK-NOT: movsd
; CHECK: punpcklwd
; CHECK-NEXT: paddw
; CHECK-NEXT: pshufb
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test6
; CHECK-WIDE-NOT: mov
; CHECK-WIDE-NOT: punpcklwd
; CHECK-WIDE: paddw
; CHECK-WIDE-NEXT: ret
define double @test7(double %A, double %B) {
@ -101,6 +135,12 @@ define double @test7(double %A, double %B) {
; CHECK-NOT: punpcklwd
; CHECK: paddw
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test7
; CHECK-WIDE-NOT: movsd
; CHECK-WIDE-NOT: punpcklwd
; CHECK-WIDE: paddw
; CHECK-WIDE-NEXT: ret
define double @test8(double %A) {
@ -111,14 +151,20 @@ define double @test8(double %A) {
}
; FIXME: Ideally we should be able to fold the entire body of @test8 into a
; single paddb instruction. At the moment we produce the sequence
; pshufd+paddw+pshufd.
; pshufd+paddw+pshufd. This is fixed with the widening legalization.
;
; CHECK-LABEL: test8
; CHECK-NOT: movsd
; CHECK: punpcklbw
; CHECK-NEXT: paddb
; CHECK-NEXT: pshufb
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test8
; CHECK-WIDE-NOT: movsd
; CHECK-WIDE-NOT: punpcklbw
; CHECK-WIDE: paddb
; CHECK-WIDE-NEXT: ret
define double @test9(double %A, double %B) {
@ -133,4 +179,10 @@ define double @test9(double %A, double %B) {
; CHECK-NOT: punpcklbw
; CHECK: paddb
; CHECK-NEXT: ret
;
; CHECK-WIDE-LABEL: test9
; CHECK-WIDE-NOT: movsd
; CHECK-WIDE-NOT: punpcklbw
; CHECK-WIDE: paddb
; CHECK-WIDE-NEXT: ret