aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/fadd-combines.ll
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 10:51:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 10:51:19 +0000
commiteb11fae6d08f479c0799db45860a98af528fa6e7 (patch)
tree44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /test/CodeGen/X86/fadd-combines.ll
parentb8a2042aa938069e862750553db0e4d82d25822c (diff)
downloadsrc-eb11fae6d08f479c0799db45860a98af528fa6e7.tar.gz
src-eb11fae6d08f479c0799db45860a98af528fa6e7.zip
Vendor import of llvm trunk r338150:vendor/llvm/llvm-trunk-r338150
Notes
Notes: svn path=/vendor/llvm/dist/; revision=336809 svn path=/vendor/llvm/llvm-trunk-r338150/; revision=336814; tag=vendor/llvm/llvm-trunk-r338150
Diffstat (limited to 'test/CodeGen/X86/fadd-combines.ll')
-rw-r--r--test/CodeGen/X86/fadd-combines.ll18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CodeGen/X86/fadd-combines.ll b/test/CodeGen/X86/fadd-combines.ll
index ce7ee94e0fbd..f9d899e44dae 100644
--- a/test/CodeGen/X86/fadd-combines.ll
+++ b/test/CodeGen/X86/fadd-combines.ll
@@ -221,4 +221,22 @@ define <4 x float> @fadd_fadd_x_x_fadd_x_x_4f32(<4 x float> %x) #0 {
ret <4 x float> %z
}
+; ((x + 42.0) + 17.0) + (x + 42.0) --> (x + 59.0) + (x + 17.0)
+; It's still 3 adds, but the first 2 are independent.
+; More reassocation could get this to 2 adds or 1 FMA (that's done in IR, but not in the DAG).
+
+define float @fadd_const_multiuse_attr(float %x) #0 {
+; CHECK-LABEL: fadd_const_multiuse_attr:
+; CHECK: # %bb.0:
+; CHECK-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; CHECK-NEXT: addss %xmm0, %xmm1
+; CHECK-NEXT: addss {{.*}}(%rip), %xmm0
+; CHECK-NEXT: addss %xmm1, %xmm0
+; CHECK-NEXT: retq
+ %a1 = fadd float %x, 42.0
+ %a2 = fadd float %a1, 17.0
+ %a3 = fadd float %a1, %a2
+ ret float %a3
+}
+
attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" "no-signed-zeros-fp-math"="true" }