1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -reassociate -S < %s | FileCheck %s
4 declare void @use(float)
6 define void @test1(float %x, float %y) {
8 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[Y:%.*]], [[X:%.*]]
9 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[Y]], [[X]]
10 ; CHECK-NEXT: [[TMP3:%.*]] = fsub fast float [[TMP1]], [[TMP2]]
11 ; CHECK-NEXT: call void @use(float [[TMP1]])
12 ; CHECK-NEXT: call void @use(float [[TMP3]])
13 ; CHECK-NEXT: ret void
15 %1 = fmul fast float %x, %y
16 %2 = fmul fast float %y, %x
17 %3 = fsub fast float %1, %2
18 call void @use(float %1)
19 call void @use(float %3)
23 define float @test2(float %x, float %y) {
24 ; CHECK-LABEL: @test2(
25 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[Y:%.*]], [[X:%.*]]
26 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[Y]], [[X]]
27 ; CHECK-NEXT: [[TMP3:%.*]] = fsub fast float [[TMP1]], [[TMP2]]
28 ; CHECK-NEXT: ret float [[TMP3]]
30 %1 = fmul fast float %x, %y
31 %2 = fmul fast float %y, %x
32 %3 = fsub fast float %1, %2
36 define float @test3(float %x, float %y) {
37 ; CHECK-LABEL: @test3(
38 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float [[Y:%.*]], [[X:%.*]]
39 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[FACTOR]], 2.000000e+00
40 ; CHECK-NEXT: ret float [[REASS_MUL]]
42 %1 = fmul fast float %x, %y
43 %2 = fmul fast float %y, %x
44 %3 = fadd fast float %1, %2