xref: /llvm-project/llvm/test/Transforms/GVN/fpmath.ll (revision 0676acb6fd8d5e22fde16e6ec977ceac08427ab0)
1; RUN: opt -passes=gvn -S < %s | FileCheck %s
2
3define double @test1(double %x, double %y) {
4; CHECK: @test1(double %x, double %y)
5; CHECK: %add1 = fadd double %x, %y
6; CHECK-NOT: fpmath
7; CHECK: %foo = fadd double %add1, %add1
8  %add1 = fadd double %x, %y, !fpmath !0
9  %add2 = fadd double %x, %y
10  %foo = fadd double %add1, %add2
11  ret double %foo
12}
13
14define double @test2(double %x, double %y) {
15; CHECK: @test2(double %x, double %y)
16; CHECK: %add1 = fadd double %x, %y, !fpmath !0
17; CHECK: %foo = fadd double %add1, %add1
18  %add1 = fadd double %x, %y, !fpmath !0
19  %add2 = fadd double %x, %y, !fpmath !0
20  %foo = fadd double %add1, %add2
21  ret double %foo
22}
23
24define double @test3(double %x, double %y) {
25; CHECK: @test3(double %x, double %y)
26; CHECK: %add1 = fadd double %x, %y, !fpmath !1
27; CHECK: %foo = fadd double %add1, %add1
28  %add1 = fadd double %x, %y, !fpmath !1
29  %add2 = fadd double %x, %y, !fpmath !0
30  %foo = fadd double %add1, %add2
31  ret double %foo
32}
33
34define double @test4(double %x, double %y) {
35; CHECK: @test4(double %x, double %y)
36; CHECK: %add1 = fadd double %x, %y, !fpmath !1
37; CHECK: %foo = fadd double %add1, %add1
38  %add1 = fadd double %x, %y, !fpmath !0
39  %add2 = fadd double %x, %y, !fpmath !1
40  %foo = fadd double %add1, %add2
41  ret double %foo
42}
43
44define double @test5(double %x, double %y) {
45; CHECK: @test5(double %x, double %y)
46; CHECK: %neg1 = fneg double %x, !fpmath !1
47; CHECK: %foo = fadd double %neg1, %neg1
48  %neg1 = fneg double %x, !fpmath !0
49  %neg2 = fneg double %x, !fpmath !1
50  %foo = fadd double %neg1, %neg2
51  ret double %foo
52}
53
54!0 = !{ float 5.0 }
55!1 = !{ float 2.5 }
56