1 ; RUN: opt -reassociate -S < %s | FileCheck %s
3 declare void @use(float)
5 define void @test1(float %x, float %y) {
7 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float %y, %x
8 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float %y, %x
9 ; CHECK-NEXT: [[TMP3:%.*]] = fsub fast float [[TMP1]], [[TMP2]]
10 ; CHECK-NEXT: call void @use(float [[TMP1]])
11 ; CHECK-NEXT: call void @use(float [[TMP3]])
12 ; CHECK-NEXT: ret void
14 %1 = fmul fast float %x, %y
15 %2 = fmul fast float %y, %x
16 %3 = fsub fast float %1, %2
17 call void @use(float %1)
18 call void @use(float %3)
22 define float @test2(float %x, float %y) {
23 ; CHECK-LABEL: @test2(
24 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float %y, %x
25 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float %y, %x
26 ; CHECK-NEXT: [[TMP3:%.*]] = fsub fast float [[TMP1]], [[TMP2]]
27 ; CHECK-NEXT: ret float [[TMP3]]
29 %1 = fmul fast float %x, %y
30 %2 = fmul fast float %y, %x
31 %3 = fsub fast float %1, %2
35 define float @test3(float %x, float %y) {
36 ; CHECK-LABEL: @test3(
37 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float %y, %x
38 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[FACTOR]], 2.000000e+00
39 ; CHECK-NEXT: ret float [[REASS_MUL]]
41 %1 = fmul fast float %x, %y
42 %2 = fmul fast float %y, %x
43 %3 = fadd fast float %1, %2