This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/22199] Unnecessary casts for comparison
- 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: 27 Jun 2005 15:17:46 -0000
- Subject: [Bug tree-optimization/22199] Unnecessary casts for comparison
- References: <20050627150444.22199.tkoenig@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-27 15:17 -------
A better example as on 32bit targets long and int are the same size which removes the casts:
extern long long int llabs (long long int __x) __attribute__ ((__const__));
int main()
{
int a,b;
foo(&a, &b);
if (llabs(a) > b)
return 1;
else
return 0;
}
Or just as good:
extern int abs (int __x) __attribute__ ((__const__));
void foo(short *, short*);
int main()
{
short a,b;
foo(&a, &b);
if (abs(a) > b)
return 1;
else
return 0;
}
Though only the first one will have different asm and will be better optimized.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-06-27 15:17:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22199