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
9b9bfcf4
Commit
9b9bfcf4
authored
Feb 11, 2010
by
Michael Beck
Browse files
Reformat ugly if sequence and renamed variables to make it mode readable.
Moved comments AFTER the ifs (where they belong to). [r27117]
parent
2af4a979
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/ir/iropt.c
View file @
9b9bfcf4
...
@@ -454,117 +454,93 @@ static tarval *computed_value_Confirm(const ir_node *n) {
...
@@ -454,117 +454,93 @@ static tarval *computed_value_Confirm(const ir_node *n) {
* There are several case where we can evaluate a Cmp node, see later.
* There are several case where we can evaluate a Cmp node, see later.
*/
*/
static
tarval
*
computed_value_Proj_Cmp
(
const
ir_node
*
n
)
{
static
tarval
*
computed_value_Proj_Cmp
(
const
ir_node
*
n
)
{
ir_node
*
a
=
get_Proj_pred
(
n
);
ir_node
*
cmp
=
get_Proj_pred
(
n
);
ir_node
*
aa
=
get_Cmp_left
(
a
);
ir_node
*
left
=
get_Cmp_left
(
cmp
);
ir_node
*
ab
=
get_Cmp_right
(
a
);
ir_node
*
right
=
get_Cmp_right
(
cmp
);
long
proj_nr
=
get_Proj_proj
(
n
);
long
pn_cmp
=
get_Proj_proj
(
n
);
ir_mode
*
mode
=
get_irn_mode
(
left
);
tarval
*
tv_l
,
*
tv_r
;
/*
/*
* BEWARE: a == a is NOT always True for floating Point values, as
* BEWARE: a == a is NOT always True for floating Point values, as
* NaN != NaN is defined, so we must check this here.
* NaN != NaN is defined, so we must check this here.
*/
*/
if
(
aa
==
ab
&&
(
if
(
left
==
right
&&
(
!
mode_is_float
(
mode
)
||
pn_cmp
==
pn_Cmp_Lt
||
pn_cmp
==
pn_Cmp_Gt
))
{
!
mode_is_float
(
get_irn_mode
(
aa
))
||
proj_nr
==
pn_Cmp_Lt
||
proj_nr
==
pn_Cmp_Gt
)
)
{
/* 1.: */
/* This is a trick with the bits used for encoding the Cmp
/* This is a trick with the bits used for encoding the Cmp
Proj numbers, the following statement is not the same:
Proj numbers, the following statement is not the same:
return new_tarval_from_long
(p
roj_nr
== pn_Cmp_Eq, mode_b) */
return new_tarval_from_long(p
n_cmp
== pn_Cmp_Eq, mode_b) */
return
new_tarval_from_long
(
p
roj_nr
&
pn_Cmp_Eq
,
mode_b
);
return
new_tarval_from_long
(
p
n_cmp
&
pn_Cmp_Eq
,
mode_b
);
}
}
tarval
*
taa
=
value_of
(
aa
);
tv_l
=
value_of
(
left
);
tarval
*
tab
=
value_of
(
ab
);
tv_r
=
value_of
(
right
);
ir_mode
*
mode
=
get_irn_mode
(
aa
);
/*
if
((
tv_l
!=
tarval_bad
)
&&
(
tv_r
!=
tarval_bad
))
{
* The predecessors of Cmp are target values. We can evaluate
/*
* the Cmp.
* The predecessors of Cmp are target values. We can evaluate
*/
* the Cmp.
if
((
taa
!=
tarval_bad
)
&&
(
tab
!=
tarval_bad
))
{
*/
/* strange checks... */
pn_Cmp
flags
=
tarval_cmp
(
tv_l
,
tv_r
);
pn_Cmp
flags
=
tarval_cmp
(
taa
,
tab
);
if
(
flags
!=
pn_Cmp_False
)
{
if
(
flags
!=
pn_Cmp_False
)
{
return
new_tarval_from_long
(
proj_nr
&
flags
,
mode_b
);
return
new_tarval_from_long
(
pn_cmp
&
flags
,
mode_b
);
}
}
}
}
else
if
(
mode_is_int
(
mode
))
{
/* for integer values, we can check against MIN/MAX */
/* for integer values, we can check against MIN/MAX */
else
if
(
mode_is_int
(
mode
))
{
pn_Cmp
cmp_result
;
/* MIN <=/> x. This results in true/false. */
if
(
taa
==
get_mode_min
(
mode
))
{
if
(
tv_l
==
get_mode_min
(
mode
))
{
/* a compare with the MIN value */
/* MIN <=/> x. This results in true/false. */
if
(
proj_nr
==
pn_Cmp_Le
)
if
(
pn_cmp
==
pn_Cmp_Le
)
return
get_tarval_b_true
();
return
tarval_b_true
;
else
if
(
proj_nr
==
pn_Cmp_Gt
)
else
if
(
pn_cmp
==
pn_Cmp_Gt
)
return
get_tarval_b_false
();
return
tarval_b_false
;
}
}
else
if
(
tv_r
==
get_mode_min
(
mode
))
{
/* x >=/< MIN. This results in true/false. */
/* x >=/< MIN. This results in true/false. */
else
if
(
pn_cmp
==
pn_Cmp_Ge
)
if
(
tab
==
get_mode_min
(
mode
))
{
return
tarval_b_true
;
/* a compare with the MIN value */
else
if
(
pn_cmp
==
pn_Cmp_Lt
)
if
(
proj_nr
==
pn_Cmp_Ge
)
return
tarval_b_false
;
return
get_tarval_b_true
();
}
else
if
(
tv_l
==
get_mode_max
(
mode
))
{
else
if
(
proj_nr
==
pn_Cmp_Lt
)
/* MAX >=/< x. This results in true/false. */
return
get_tarval_b_false
();
if
(
pn_cmp
==
pn_Cmp_Ge
)
}
return
tarval_b_true
;
/* MAX >=/< x. This results in true/false. */
else
if
(
pn_cmp
==
pn_Cmp_Lt
)
else
if
(
taa
==
get_mode_max
(
mode
))
{
return
tarval_b_false
;
if
(
proj_nr
==
pn_Cmp_Ge
)
}
else
if
(
tv_r
==
get_mode_max
(
mode
))
{
return
get_tarval_b_true
();
/* x <=/> MAX. This results in true/false. */
else
if
(
proj_nr
==
pn_Cmp_Lt
)
if
(
pn_cmp
==
pn_Cmp_Le
)
return
get_tarval_b_false
();
return
tarval_b_true
;
}
else
if
(
pn_cmp
==
pn_Cmp_Gt
)
/* x <=/> MAX. This results in true/false. */
return
tarval_b_false
;
else
if
(
tab
==
get_mode_max
(
mode
))
{
}
if
(
proj_nr
==
pn_Cmp_Le
)
return
get_tarval_b_true
();
cmp_result
=
vrp_cmp
(
left
,
right
);
else
if
(
proj_nr
==
pn_Cmp_Gt
)
return
get_tarval_b_false
();
}
pn_Cmp
cmp_result
=
vrp_cmp
(
aa
,
ab
);
if
(
cmp_result
!=
pn_Cmp_False
)
{
if
(
cmp_result
!=
pn_Cmp_False
)
{
if
(
cmp_result
==
pn_Cmp_Lg
)
{
if
(
cmp_result
==
pn_Cmp_Lg
)
{
if
(
proj_nr
==
pn_Cmp_Eq
)
{
if
(
pn_cmp
==
pn_Cmp_Eq
)
{
return
get_
tarval_b_false
()
;
return
tarval_b_false
;
}
else
if
(
p
roj_nr
==
pn_Cmp_Lg
)
{
}
else
if
(
p
n_cmp
==
pn_Cmp_Lg
)
{
return
get_
tarval_b_true
()
;
return
tarval_b_true
;
}
}
}
else
{
}
else
{
return
new_tarval_from_long
(
cmp_result
&
p
roj_nr
,
mode_b
);
return
new_tarval_from_long
(
cmp_result
&
p
n_cmp
,
mode_b
);
}
}
}
}
}
else
if
(
mode_is_reference
(
mode
))
{
/* pointer compare */
ir_node
*
s_l
=
skip_Proj
(
left
);
ir_node
*
s_r
=
skip_Proj
(
right
);
if
((
is_Alloc
(
s_l
)
&&
tarval_is_null
(
tv_r
))
||
(
tarval_is_null
(
tv_l
)
&&
is_Alloc
(
s_r
)))
{
/*
* The predecessors are Allocs and (void*)(0) constants. In Firm Allocs never
* return NULL, they raise an exception. Therefore we can predict
* the Cmp result.
*/
return
new_tarval_from_long
(
pn_cmp
&
pn_Cmp_Lg
,
mode_b
);
}
}
}
/*
return
computed_value_Cmp_Confirm
(
cmp
,
left
,
right
,
pn_cmp
);
* The predecessors are Allocs or (void*)(0) constants. Allocs never
* return NULL, they raise an exception. Therefore we can predict
* the Cmp result.
*/
else
{
ir_node
*
aaa
=
skip_Proj
(
aa
);
ir_node
*
aba
=
skip_Proj
(
ab
);
if
(
(
(
/* aa is ProjP and aaa is Alloc */
is_Proj
(
aa
)
&&
mode_is_reference
(
get_irn_mode
(
aa
))
&&
is_Alloc
(
aaa
))
&&
(
(
/* ab is NULL */
mode_is_reference
(
get_irn_mode
(
ab
))
&&
tarval_is_null
(
tab
))
||
(
/* ab is other Alloc */
is_Proj
(
ab
)
&&
mode_is_reference
(
get_irn_mode
(
ab
))
&&
is_Alloc
(
aba
)
&&
(
aaa
!=
aba
))))
||
(
/* aa is NULL and aba is Alloc */
mode_is_reference
(
get_irn_mode
(
aa
))
&&
tarval_is_null
(
taa
)
&&
is_Proj
(
ab
)
&&
mode_is_reference
(
get_irn_mode
(
ab
))
&&
is_Alloc
(
aba
)))
/* 3.: */
return
new_tarval_from_long
(
proj_nr
&
pn_Cmp_Lg
,
mode_b
);
}
return
computed_value_Cmp_Confirm
(
a
,
aa
,
ab
,
proj_nr
);
}
/* computed_value_Proj_Cmp */
}
/* computed_value_Proj_Cmp */
/**
/**
...
...
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