[Bug rtl-optimization/25600] New: unsigned>>31?-1:0 should be optimized to int>>31
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Dec 30 05:56:00 GMT 2005
The following functions should produce the same asm (only f3 and f1 produce the
optimial code):
int f(unsigned x)
{
return x >> 31 ? -1 : 0;
}
int f2(int x)
{
return x >> 31 ? -1 : 0;
}
int f1(int x)
{
return (x >> 31);
}
int f3(unsigned x)
{
return (-(x>>31));
}
int f4(unsigned x)
{
x = x>>31;
return -x;
}
-----
The reason why I am putting this in the rtl-opt component is because one we
don't have a tree combiner (as fold already does it), two if we did get a tree
combiner, f and f2 will not be fixed.
I should mention that f and f2 are different problems on the rtl level but I am
too lazy to file two different bugs.
Also this does show up in real code, see PR 25578 for where it shows up in MPFR
which is used in GCC.
--
Summary: unsigned>>31?-1:0 should be optimized to int>>31
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25600
More information about the Gcc-bugs
mailing list