[Bug tree-optimization/80153] ivopt generate wrong code
amker at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Mar 24 17:30:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80153
--- Comment #7 from amker at gcc dot gnu.org ---
Case gcc.dg/tree-ssa/reassoc-19 failed, the ivopt dump before change is:
<bb 2> [15.00%]:
goto <bb 4>; [100.00%]
<bb 3> [85.00%]:
_1 = (sizetype) element_8(D);
_2 = -_1;
_12 = (unsigned long) element_8(D);
_11 = -_12;
_13 = rite_3 + _11;
rite_9 = _13;
bar (left_7(D), rite_9, element_8(D));
<bb 4> [100.00%]:
# rite_3 = PHI <rite_5(D)(2), rite_9(3)>
if (rite_3 >= left_7(D))
goto <bb 3>; [85.00%]
else
goto <bb 5>; [15.00%]
<bb 5> [15.00%]:
return;
But changed to below after change:
<bb 2> [15.00%]:
goto <bb 4>; [100.00%]
<bb 3> [85.00%]:
_1 = (sizetype) element_8(D);
_2 = -_1;
_12 = (unsigned long) rite_3;
_11 = (unsigned long) element_8(D);
_13 = _12 - _11;
_14 = (char *) _13;
rite_9 = _14;
bar (left_7(D), rite_9, element_8(D));
<bb 4> [100.00%]:
# rite_3 = PHI <rite_5(D)(2), rite_9(3)>
if (rite_3 >= left_7(D))
goto <bb 3>; [85.00%]
else
goto <bb 5>; [15.00%]
<bb 5> [15.00%]:
return;
I don't think this is real regression here, assembly code is the same. The
additional type conversion is introduced by get_computation_aff. Though we
have
utype: char *
ctype: char *
var->typed.type: char *
The function still computes the expression in uutype:
uutype = unsigned_type_for (utype);
which is unsigned long here.
Actually, given the computation sequence:
if (common_type != uutype)
aff_combination_convert (aff, uutype);
aff_combination_scale (&var_aff, rat);
aff_combination_add (aff, &var_aff);
I think type conversion is needed. Of course, get_computation_aff should not
introduce unnecessary uutype conversion.
More information about the Gcc-bugs
mailing list