1 ; RUN: opt < %s -reassociate -S | FileCheck %s
3 define float @test1(float %A) {
5 ; CHECK-NEXT: [[X:%.*]] = fadd float %A, 1.000000e+00
6 ; CHECK-NEXT: [[Y:%.*]] = fadd float %A, 1.000000e+00
7 ; CHECK-NEXT: [[R:%.*]] = fsub float [[X]], [[Y]]
8 ; CHECK-NEXT: ret float [[R]]
10 %X = fadd float %A, 1.000000e+00
11 %Y = fadd float %A, 1.000000e+00
12 %r = fsub float %X, %Y
16 define float @test2(float %A) {
17 ; CHECK-LABEL: @test2(
18 ; CHECK-NEXT: ret float 0.000000e+00
20 %X = fadd fast float 1.000000e+00, %A
21 %Y = fadd fast float 1.000000e+00, %A
22 %r = fsub fast float %X, %Y
26 ; Check again using minimal subset of FMF.
28 define float @test2_reassoc(float %A) {
29 ; CHECK-LABEL: @test2_reassoc(
30 ; CHECK-NEXT: [[X:%.*]] = fadd reassoc float %A, 1.000000e+00
31 ; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float %A, 1.000000e+00
32 ; CHECK-NEXT: [[R:%.*]] = fsub reassoc float [[X]], [[Y]]
33 ; CHECK-NEXT: ret float [[R]]
35 %X = fadd reassoc float 1.000000e+00, %A
36 %Y = fadd reassoc float 1.000000e+00, %A
37 %r = fsub reassoc float %X, %Y