This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/30966] New: (long long)(int_var) == (long long)(int_var1) is not simplified down to int_var == int_var1 when "expanded"
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Feb 2007 11:35:50 -0000
- Subject: [Bug tree-optimization/30966] New: (long long)(int_var) == (long long)(int_var1) is not simplified down to int_var == int_var1 when "expanded"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Both of these functions should produce the same asm:
int f(int a, int b)
{
long long c = a;
long long d = b;
return c == d;
}
int f1(int a, int b)
{
return ((long long) a) == ((long long)b);
}
But don't at least on powerpc-darwin:
_f:
srawi r0,r3,31
srawi r2,r4,31
cmpw cr7,r0,r2
mr r9,r3
li r3,0
bnelr+ cr7
cmpw cr7,r9,r4
bnelr+ cr7
li r3,1
blr
_f1:
xor r3,r3,r4
cntlzw r3,r3
srwi r3,r3,5
blr
Even powerpc64-darwin does not produce the same asm, in this case f1 is worse
than f:
_f:
xor r3,r3,r4
cntlzd r3,r3
srdi r3,r3,6
blr
_f1:
xor r4,r3,r4
cntlzw r4,r4
srwi r4,r4,5
extsw r3,r4
blr
But only because there is an extra sign extends (I will file this in a
different bug).
--
Summary: (long long)(int_var) == (long long)(int_var1) is not
simplified down to int_var == int_var1 when "expanded"
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-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=30966