From: Simon Pilgrim Date: Sat, 3 Oct 2015 18:17:43 +0000 (+0000) Subject: [X86][SSE] Add FADD combine tests. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=58d1cc109acf336bfcf311f198cc2d45efd7d15b;p=oota-llvm.git [X86][SSE] Add FADD combine tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249240 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGen/X86/fadd-combines.ll b/test/CodeGen/X86/fadd-combines.ll new file mode 100644 index 00000000000..5eb455d14c1 --- /dev/null +++ b/test/CodeGen/X86/fadd-combines.ll @@ -0,0 +1,196 @@ +; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s + +define float @fadd_zero_f32(float %x) #0 { +; CHECK-LABEL: fadd_zero_f32: +; CHECK: # BB#0: +; CHECK-NEXT: retq + %y = fadd float %x, 0.0 + ret float %y +} + +define <4 x float> @fadd_zero_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_zero_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: xorps %xmm1, %xmm1 +; CHECK-NEXT: addps %xmm1, %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, zeroinitializer + ret <4 x float> %y +} + +define float @fadd_2const_f32(float %x) #0 { +; CHECK-LABEL: fadd_2const_f32: +; CHECK: # BB#0: +; CHECK-NEXT: addss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd float %x, 1.0 + %z = fadd float %y, 2.0 + ret float %z +} + +define <4 x float> @fadd_2const_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_2const_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: addps {{.*}}(%rip), %xmm0 +; CHECK-NEXT: addps {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, + %z = fadd <4 x float> %y, + ret <4 x float> %z +} + +define float @fadd_x_fmul_x_c_f32(float %x) #0 { +; CHECK-LABEL: fadd_x_fmul_x_c_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fmul float %x, 2.0 + %z = fadd float %x, %y + ret float %z +} + +define <4 x float> @fadd_x_fmul_x_c_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_x_fmul_x_c_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm1 = [1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00] +; CHECK-NEXT: mulps %xmm0, %xmm1 +; CHECK-NEXT: addps %xmm1, %xmm0 +; CHECK-NEXT: retq + %y = fmul <4 x float> %x, + %z = fadd <4 x float> %x, %y + ret <4 x float> %z +} + +define float @fadd_fmul_x_c_x_f32(float %x) #0 { +; CHECK-LABEL: fadd_fmul_x_c_x_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fmul float %x, 2.0 + %z = fadd float %y, %x + ret float %z +} + +define <4 x float> @fadd_fmul_x_c_x_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_fmul_x_c_x_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm1 = [1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00] +; CHECK-NEXT: mulps %xmm0, %xmm1 +; CHECK-NEXT: addps %xmm1, %xmm0 +; CHECK-NEXT: retq + %y = fmul <4 x float> %x, + %z = fadd <4 x float> %y, %x + ret <4 x float> %z +} + +define float @fadd_fadd_x_x_fmul_x_c_f32(float %x) #0 { +; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd float %x, %x + %z = fmul float %x, 2.0 + %w = fadd float %y, %z + ret float %w +} + +define <4 x float> @fadd_fadd_x_x_fmul_x_c_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm1 = [1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00] +; CHECK-NEXT: mulps %xmm0, %xmm1 +; CHECK-NEXT: addps %xmm0, %xmm1 +; CHECK-NEXT: addps %xmm1, %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, %x + %z = fmul <4 x float> %x, + %w = fadd <4 x float> %y, %z + ret <4 x float> %w +} + +define float @fadd_fmul_x_c_fadd_x_x_f32(float %x) #0 { +; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd float %x, %x + %z = fmul float %x, 2.0 + %w = fadd float %z, %y + ret float %w +} + +define <4 x float> @fadd_fmul_x_c_fadd_x_x_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm1 = [1.000000e+00,2.000000e+00,3.000000e+00,4.000000e+00] +; CHECK-NEXT: mulps %xmm0, %xmm1 +; CHECK-NEXT: addps %xmm0, %xmm1 +; CHECK-NEXT: addps %xmm1, %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, %x + %z = fmul <4 x float> %x, + %w = fadd <4 x float> %z, %y + ret <4 x float> %w +} + +define float @fadd_x_fadd_x_x_f32(float %x) #0 { +; CHECK-LABEL: fadd_x_fadd_x_x_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd float %x, %x + %z = fadd float %x, %y + ret float %z +} + +define <4 x float> @fadd_x_fadd_x_x_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_x_fadd_x_x_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, %x + %z = fadd <4 x float> %x, %y + ret <4 x float> %z +} + +define float @fadd_fadd_x_x_x_f32(float %x) #0 { +; CHECK-LABEL: fadd_fadd_x_x_x_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd float %x, %x + %z = fadd float %y, %x + ret float %z +} + +define <4 x float> @fadd_fadd_x_x_x_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_fadd_x_x_x_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, %x + %z = fadd <4 x float> %y, %x + ret <4 x float> %z +} + +define float @fadd_fadd_x_x_fadd_x_x_f32(float %x) #0 { +; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd float %x, %x + %z = fadd float %y, %y + ret float %z +} + +define <4 x float> @fadd_fadd_x_x_fadd_x_x_4f32(<4 x float> %x) #0 { +; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_4f32: +; CHECK: # BB#0: +; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0 +; CHECK-NEXT: retq + %y = fadd <4 x float> %x, %x + %z = fadd <4 x float> %y, %y + ret <4 x float> %z +} + +attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" }