[llvm] r212254 - [x86] Fix crashes in lowering bitcast instructions with the widening
Andrea Di Biagio
andrea.dibiagio at gmail.com
Thu Jul 3 03:19:32 PDT 2014
Really cool! Thanks :)
On Thu, Jul 3, 2014 at 4:43 AM, Chandler Carruth <chandlerc at gmail.com> wrote:
> Author: chandlerc
> Date: Wed Jul 2 22:43:47 2014
> New Revision: 212254
>
> URL: http://llvm.org/viewvc/llvm-project?rev=212254&view=rev
> Log:
> [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.
>
> Modified:
> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> llvm/trunk/test/CodeGen/X86/lower-bitcast.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=212254&r1=212253&r2=212254&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 2 22:43:47 2014
> @@ -16410,6 +16410,13 @@ void X86TargetLowering::ReplaceNodeResul
> 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,
>
> Modified: llvm/trunk/test/CodeGen/X86/lower-bitcast.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lower-bitcast.ll?rev=212254&r1=212253&r2=212254&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/lower-bitcast.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/lower-bitcast.ll Wed Jul 2 22:43:47 2014
> @@ -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 %
> ; 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 %
> ; 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 %
> ; 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
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list