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
445d6c9b
Commit
445d6c9b
authored
Aug 18, 2014
by
Matthias Braun
Browse files
slightly simplify lea(x>>2,x>>2,4) matcher
parent
2aba2bc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/be/ia32/x86_address_mode.c
View file @
445d6c9b
...
@@ -375,35 +375,36 @@ void x86_create_address_mode(x86_address_t *addr, ir_node *node,
...
@@ -375,35 +375,36 @@ void x86_create_address_mode(x86_address_t *addr, ir_node *node,
/* (x & 0xFFFFFFFC) + (x >> 2) -> lea(x >> 2, x >> 2, 4) */
/* (x & 0xFFFFFFFC) + (x >> 2) -> lea(x >> 2, x >> 2, 4) */
if
(
left
!=
NULL
&&
right
!=
NULL
)
{
if
(
left
!=
NULL
&&
right
!=
NULL
)
{
ir_node
*
and
=
NULL
;
ir_node
*
and
;
ir_node
*
shr
=
NULL
;
ir_node
*
shr
;
if
(
is_And
(
left
)
&&
(
is_Shr
(
right
)
||
is_Shrs
(
right
)))
{
if
(
is_And
(
left
)
&&
(
is_Shr
(
right
)
||
is_Shrs
(
right
)))
{
and
=
left
;
and
=
left
;
shr
=
right
;
shr
=
right
;
}
else
if
(
is_And
(
right
)
&&
(
is_Shr
(
left
)
||
is_Shrs
(
left
)))
{
goto
tryit
;
}
if
(
is_And
(
right
)
&&
(
is_Shr
(
left
)
||
is_Shrs
(
left
)))
{
and
=
right
;
and
=
right
;
shr
=
left
;
shr
=
left
;
}
tryit:
if
(
get_And_left
(
and
)
==
get_binop_left
(
shr
))
{
if
(
and
!=
NULL
&&
get_And_
lef
t
(
and
)
==
get_binop_left
(
shr
))
{
ir_node
*
and_right
=
get_And_
righ
t
(
and
)
;
ir_node
*
and
_right
=
get_
And
_right
(
and
);
ir_node
*
shr
_right
=
get_
binop
_right
(
shr
);
ir_node
*
shr_right
=
get_binop_right
(
shr
);
if
(
is_Const
(
and_right
)
&&
is_Const
(
shr_right
))
{
if
(
is_Const
(
and_right
)
&&
is_Const
(
shr
_right
)
)
{
ir_tarval
*
and_mask
=
get_Const_tarval
(
and
_right
)
;
ir_tarval
*
and_mask
=
get_Const_tarval
(
and
_right
);
ir_tarval
*
shift_amount
=
get_Const_tarval
(
shr
_right
);
ir_
tarval
*
shift_amount
=
get_Const_tarval
(
shr_right
);
ir_
mode
*
mode
=
get_irn_mode
(
and
);
ir_
mode
*
mode
=
get_irn_mode
(
and
);
ir_
tarval
*
all_one
=
get_mode_all_one
(
mode
);
ir_tarval
*
all_one
=
get_mode_all_one
(
mode
);
ir_tarval
*
shift_mask
=
tarval_shl
(
tarval_shr
(
all_one
,
shift_amount
),
shift_amount
);
ir_tarval
*
shift_mask
=
tarval_shl
(
tarval_shr
(
all_one
,
shift_amount
),
shift_amount
);
assert
(
tarval_is_long
(
shift_amount
)
);
assert
(
tarval_
is_
long
(
shift_amount
)
)
;
long
val
=
get_
tarval_long
(
shift_amount
);
long
val
=
get_tarval_long
(
shift_amount
);
if
(
and_mask
==
shift_mask
&&
val
>=
0
&&
val
<=
3
)
{
if
(
and_mask
==
shift_mask
&&
val
>=
0
&&
val
<=
3
)
{
addr
->
base
=
shr
;
addr
->
base
=
shr
;
addr
->
index
=
shr
;
addr
->
index
=
shr
;
addr
->
scale
=
val
;
addr
->
scale
=
val
;
return
;
return
;
}
}
}
}
}
}
}
...
...
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