Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
48c9f5c9
Commit
48c9f5c9
authored
Mar 20, 2014
by
yb9976
Browse files
Generalized ~x + 1 => -x to ~x + C => (C - 1) - x.
parent
736159f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/ir/iropt.c
View file @
48c9f5c9
...
...
@@ -2706,12 +2706,20 @@ static ir_node *transform_node_Add(ir_node *n)
if
(
is_Not
(
a
))
{
ir_node
*
op
=
get_Not_op
(
a
);
if
(
is_Const
(
b
)
&&
is_Const_one
(
b
))
{
/* ~x + 1 = -x */
ir_node
*
blk
=
get_nodes_block
(
n
);
n
=
new_rd_Minus
(
get_irn_dbg_info
(
n
),
blk
,
op
,
mode
);
DBG_OPT_ALGSIM0
(
oldn
,
n
,
FS_OPT_NOT_PLUS_1
);
return
n
;
if
(
is_Const
(
b
))
{
ir_tarval
*
const
tv
=
get_Const_tarval
(
b
);
ir_tarval
*
const
minus_one
=
get_mode_minus_one
(
mode
);
ir_tarval
*
const
add
=
tarval_add
(
tv
,
minus_one
);
if
(
tarval_is_constant
(
add
))
{
/* ~x + C = (C - 1) - x */
dbg_info
*
const
dbgi
=
get_irn_dbg_info
(
n
);
ir_node
*
const
block
=
get_nodes_block
(
n
);
ir_node
*
const
c
=
new_rd_Const
(
dbgi
,
irg
,
add
);
n
=
new_rd_Sub
(
get_irn_dbg_info
(
n
),
block
,
c
,
op
,
mode
);
DBG_OPT_ALGSIM0
(
oldn
,
n
,
FS_OPT_NOT_PLUS_C
);
return
n
;
}
}
}
if
(
!
irg_is_constrained
(
irg
,
IR_GRAPH_CONSTRAINT_ARCH_DEP
))
{
...
...
ir/stat/firmstat_t.h
View file @
48c9f5c9
...
...
@@ -108,7 +108,7 @@ enum firmstat_optimizations_t {
FS_OPT_INVOLUTION
,
/**< OP(OP(x)) = x */
FS_OPT_MINUS_NOT
,
/**< -(~x) = x + 1 */
FS_OPT_NOT_MINUS_1
,
/**< ~(x - 1) = -x */
FS_OPT_NOT_PLUS_
1
,
/**< ~x +
1
=
-
x */
FS_OPT_NOT_PLUS_
C
,
/**< ~x +
C
=
(C - 1) -
x */
FS_OPT_ADD_X_NOT_X
,
/**< ~x + x = -1 */
FS_OPT_FP_INV_MUL
,
/**< x / y = x * (1.0/y) */
FS_OPT_CONST_PHI
,
/**< Constant evaluation on Phi */
...
...
ir/stat/stat_dmp.c
View file @
48c9f5c9
...
...
@@ -98,7 +98,7 @@ static const struct {
{
(
hook_opt_kind
)
FS_OPT_INVOLUTION
,
"algebraic simplification: OP(OP(x)) = x"
},
{
(
hook_opt_kind
)
FS_OPT_MINUS_NOT
,
"algebraic simplification: -(~x) = x + 1"
},
{
(
hook_opt_kind
)
FS_OPT_NOT_MINUS_1
,
"algebraic simplification: ~(x - 1) = -x"
},
{
(
hook_opt_kind
)
FS_OPT_NOT_PLUS_
1
,
"algebraic simplification: ~x +
1
=
-
x"
},
{
(
hook_opt_kind
)
FS_OPT_NOT_PLUS_
C
,
"algebraic simplification: ~x +
C
=
(C - 1) -
x"
},
{
(
hook_opt_kind
)
FS_OPT_ADD_X_NOT_X
,
"algebraic simplification: ~x + x = -1"
},
{
(
hook_opt_kind
)
FS_OPT_FP_INV_MUL
,
"algebraic simplification: x / y = x * (1.0/y)"
},
{
(
hook_opt_kind
)
FS_OPT_CONST_PHI
,
"constant evaluation on Phi node"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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