This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/22199] Unnecessary casts for comparison


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]