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
eb63de59
Commit
eb63de59
authored
Sep 22, 2014
by
yb9976
Browse files
Added local optimization: 0x7F...F - x -> x ^ 0x7F...F.
parent
a2332307
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/ir/iropt.c
View file @
eb63de59
...
...
@@ -3154,13 +3154,25 @@ static ir_node *transform_node_Sub(ir_node *n)
if
(
mode
==
lmode
&&
get_mode_arithmetic
(
mode
)
==
irma_twos_complement
&&
is_Const
(
a
)
&&
tarval_is_all_one
(
get_Const_tarval
(
a
)))
{
/* -1 - x -> ~x */
dbg_info
*
dbg
=
get_irn_dbg_info
(
n
);
n
=
new_rd_Not
(
dbg
,
get_nodes_block
(
n
),
b
,
mode
);
DBG_OPT_ALGSIM0
(
oldn
,
n
,
FS_OPT_SUB_TO_NOT
);
return
n
;
is_Const
(
a
))
{
ir_tarval
*
ta
=
get_Const_tarval
(
a
);
if
(
tarval_is_all_one
(
ta
))
{
/* -1 - x -> ~x */
dbg_info
*
dbgi
=
get_irn_dbg_info
(
n
);
ir_node
*
block
=
get_nodes_block
(
n
);
n
=
new_rd_Not
(
dbgi
,
block
,
b
,
mode
);
DBG_OPT_ALGSIM0
(
oldn
,
n
,
FS_OPT_SUB_TO_NOT
);
return
n
;
}
ir_tarval
*
all_one
=
get_mode_all_one
(
mode
);
ir_tarval
*
expected
=
tarval_shr_unsigned
(
all_one
,
1
);
if
(
tarval_and
(
ta
,
expected
)
==
expected
)
{
/* 0x7F...F - x -> x ^ 0x7F...F */
dbg_info
*
dbgi
=
get_irn_dbg_info
(
n
);
ir_node
*
block
=
get_nodes_block
(
n
);
return
new_rd_Eor
(
dbgi
,
block
,
b
,
a
,
mode
);
}
}
}
...
...
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