blob: b0957a8177395cc21fc7a0f9051713299d9ec069 [file] [log] [blame]
Michael Ilsemanbb6f6912012-12-12 00:27:46 +00001; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3; fsub 0, (fsub 0, X) ==> X
Stephen Linc1c7a132013-07-14 01:42:54 +00004; CHECK-LABEL: @fsub_0_0_x(
Michael Ilsemanbb6f6912012-12-12 00:27:46 +00005define float @fsub_0_0_x(float %a) {
6 %t1 = fsub float -0.0, %a
7 %ret = fsub float -0.0, %t1
8
9; CHECK: ret float %a
10 ret float %ret
11}
12
13; fsub X, 0 ==> X
Stephen Linc1c7a132013-07-14 01:42:54 +000014; CHECK-LABEL: @fsub_x_0(
Michael Ilsemanbb6f6912012-12-12 00:27:46 +000015define float @fsub_x_0(float %a) {
16 %ret = fsub float %a, 0.0
Benjamin Kramerb50682e2013-04-11 12:41:41 +000017; CHECK: ret float %a
Michael Ilsemanbb6f6912012-12-12 00:27:46 +000018 ret float %ret
19}
20
21; fadd X, -0 ==> X
Stephen Linc1c7a132013-07-14 01:42:54 +000022; CHECK-LABEL: @fadd_x_n0(
Michael Ilsemanbb6f6912012-12-12 00:27:46 +000023define float @fadd_x_n0(float %a) {
24 %ret = fadd float %a, -0.0
Benjamin Kramerb50682e2013-04-11 12:41:41 +000025; CHECK: ret float %a
Michael Ilsemanbb6f6912012-12-12 00:27:46 +000026 ret float %ret
27}
28
29; fmul X, 1.0 ==> X
Stephen Linc1c7a132013-07-14 01:42:54 +000030; CHECK-LABEL: @fmul_X_1(
Michael Ilsemanbb6f6912012-12-12 00:27:46 +000031define double @fmul_X_1(double %a) {
32 %b = fmul double 1.000000e+00, %a ; <double> [#uses=1]
33 ; CHECK: ret double %a
34 ret double %b
35}
Sanjay Patel40eaa8d2015-02-25 18:00:15 +000036
37; We can't optimize away the fadd in this test because the input
38; value to the function and subsequently to the fadd may be -0.0.
39; In that one special case, the result of the fadd should be +0.0
40; rather than the first parameter of the fadd.
41
42; Fragile test warning: We need 6 sqrt calls to trigger the bug
43; because the internal logic has a magic recursion limit of 6.
44; This is presented without any explanation or ability to customize.
45
46declare float @sqrtf(float)
47
48define float @PR22688(float %x) {
49 %1 = call float @sqrtf(float %x)
50 %2 = call float @sqrtf(float %1)
51 %3 = call float @sqrtf(float %2)
52 %4 = call float @sqrtf(float %3)
53 %5 = call float @sqrtf(float %4)
54 %6 = call float @sqrtf(float %5)
55 %7 = fadd float %6, 0.0
56 ret float %7
57
58; CHECK-LABEL: @PR22688(
59; CHECK: fadd float %6, 0.0
60}
61