Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
4862eaa3
Commit
4862eaa3
authored
Dec 03, 2012
by
Matthias Braun
Browse files
the 1/c -> 1*c optimisation is fine for x86 floats too
parent
b009bb03
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/ir/iropt.c
View file @
4862eaa3
...
...
@@ -3165,34 +3165,32 @@ static ir_node *transform_node_Div(ir_node *n)
assert
(
mode_is_float
(
mode
));
/* Optimize x/c to x*(1/c) */
if
(
get_mode_arithmetic
(
mode
)
==
irma_ieee754
)
{
ir_tarval
*
tv
=
value_of
(
b
);
ir_tarval
*
tv
=
value_of
(
b
);
if
(
tv
!=
tarval_bad
)
{
int
rem
=
tarval_fp_ops_enabled
();
if
(
tv
!=
tarval_bad
)
{
int
rem
=
tarval_fp_ops_enabled
();
/*
* Floating point constant folding might be disabled here to
* prevent rounding.
* However, as we check for exact result, doing it is safe.
* Switch it on.
*/
tarval_enable_fp_ops
(
1
);
tv
=
tarval_div
(
get_mode_one
(
mode
),
tv
);
tarval_enable_fp_ops
(
rem
);
/* Do the transformation if the result is either exact or we are
not using strict rules. */
if
(
tv
!=
tarval_bad
&&
(
tarval_ieee754_get_exact
()
||
(
get_irg_fp_model
(
get_irn_irg
(
n
))
&
fp_strict_algebraic
)
==
0
))
{
ir_node
*
block
=
get_nodes_block
(
n
);
ir_graph
*
irg
=
get_irn_irg
(
block
);
ir_node
*
c
=
new_r_Const
(
irg
,
tv
);
dbg_info
*
dbgi
=
get_irn_dbg_info
(
n
);
value
=
new_rd_Mul
(
dbgi
,
block
,
a
,
c
,
mode
);
/*
* Floating point constant folding might be disabled here to
* prevent rounding.
* However, as we check for exact result, doing it is safe.
* Switch it on.
*/
tarval_enable_fp_ops
(
1
);
tv
=
tarval_div
(
get_mode_one
(
mode
),
tv
);
tarval_enable_fp_ops
(
rem
);
/* Do the transformation if the result is either exact or we are
not using strict rules. */
if
(
tv
!=
tarval_bad
&&
(
tarval_ieee754_get_exact
()
||
(
get_irg_fp_model
(
get_irn_irg
(
n
))
&
fp_strict_algebraic
)
==
0
))
{
ir_node
*
block
=
get_nodes_block
(
n
);
ir_graph
*
irg
=
get_irn_irg
(
block
);
ir_node
*
c
=
new_r_Const
(
irg
,
tv
);
dbg_info
*
dbgi
=
get_irn_dbg_info
(
n
);
value
=
new_rd_Mul
(
dbgi
,
block
,
a
,
c
,
mode
);
goto
make_tuple
;
}
goto
make_tuple
;
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment