summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/fp-fast.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/CodeGen/X86/fp-fast.ll')
-rw-r--r--llvm/test/CodeGen/X86/fp-fast.ll43
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/fp-fast.ll b/llvm/test/CodeGen/X86/fp-fast.ll
index 479f60d91f1..eb2ebd9119a 100644
--- a/llvm/test/CodeGen/X86/fp-fast.ll
+++ b/llvm/test/CodeGen/X86/fp-fast.ll
@@ -113,3 +113,46 @@ define float @test11(float %a) {
%t2 = fadd float %a, %t1
ret float %t2
}
+
+; Verify that the first two adds are independent; the destination registers
+; are used as source registers for the third add.
+
+define float @reassociate_adds1(float %a, float %b, float %c, float %d) {
+; CHECK-LABEL: reassociate_adds1:
+; CHECK: # BB#0:
+; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: vaddss %xmm2, %xmm3, %xmm1
+; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: retq
+ %add0 = fadd float %a, %b
+ %add1 = fadd float %add0, %c
+ %add2 = fadd float %add1, %d
+ ret float %add2
+}
+
+define float @reassociate_adds2(float %a, float %b, float %c, float %d) {
+; CHECK-LABEL: reassociate_adds2:
+; CHECK: # BB#0:
+; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: vaddss %xmm2, %xmm3, %xmm1
+; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: retq
+ %add0 = fadd float %a, %b
+ %add1 = fadd float %c, %add0
+ %add2 = fadd float %add1, %d
+ ret float %add2
+}
+
+define float @reassociate_adds3(float %a, float %b, float %c, float %d) {
+; CHECK-LABEL: reassociate_adds3:
+; CHECK: # BB#0:
+; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: vaddss %xmm2, %xmm3, %xmm1
+; CHECK-NEXT: vaddss %xmm1, %xmm0, %xmm0
+; CHECK-NEXT: retq
+ %add0 = fadd float %a, %b
+ %add1 = fadd float %add0, %c
+ %add2 = fadd float %d, %add1
+ ret float %add2
+}
+
OpenPOWER on IntegriCloud