[Bug tree-optimization/89317] Ineffective code from std::copy
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 8 22:35:22 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89317
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |TREE
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note on the trunk, these two functions now produce the same code. BUT we are
still missing a gimple level optimization.
The RTL level can figure out:
_1 = this_6(D) + 16;
_2 = &this_6(D)->data1;
_19 = _1 - _2;
__n_20 = _19 /[ex] 2;
if (_19 > 0)
goto <bb 3>; [89.00%]
else
goto <bb 18>; [11.00%]
That _19 is 16 and the condition is always true.
Reduced testcase for that issue:
struct { int data[16]; } *x;
int foo (int n1)
{
int *a = x->data;
int *b = ((int*)x) + 4;
return b - a;
}
More information about the Gcc-bugs
mailing list