• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3; fsub 0, (fsub 0, X) ==> X
4; CHECK-LABEL: @fsub_0_0_x(
5define 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
14; CHECK-LABEL: @fsub_x_0(
15define float @fsub_x_0(float %a) {
16  %ret = fsub float %a, 0.0
17; CHECK: ret float %a
18  ret float %ret
19}
20
21; fadd X, -0 ==> X
22; CHECK-LABEL: @fadd_x_n0(
23define float @fadd_x_n0(float %a) {
24  %ret = fadd float %a, -0.0
25; CHECK: ret float %a
26  ret float %ret
27}
28
29; fmul X, 1.0 ==> X
30; CHECK-LABEL: @fmul_X_1(
31define 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}
36
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
62