• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -reassociate -S | FileCheck %s
2
3define float @test1(float %A) {
4; CHECK-LABEL: @test1(
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]]
9;
10  %X = fadd float %A, 1.000000e+00
11  %Y = fadd float %A, 1.000000e+00
12  %r = fsub float %X, %Y
13  ret float %r
14}
15
16define float @test2(float %A) {
17; CHECK-LABEL: @test2(
18; CHECK-NEXT:    ret float 0.000000e+00
19;
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
23  ret float %r
24}
25
26; Check again using minimal subset of FMF.
27
28define 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]]
34;
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
38  ret float %r
39}
40
41