$ cat labs.c
extern long int labs (long int __x) __attribute__ ((__const__));

int main()
{
    int a,b;
    foo(&a, &b);
    if (labs(a) > b)
        return 1;
    else
        return 0;
}

is translated with

$ gcc -O3 -fdump-tree-optimized -S labs.c

into

<bb 0>:
  foo (&a, &b);
  return (int) (ABS_EXPR <(long int) a> > (long int) b);

The casts aren't necessary in this case.

-- 
           Summary: Unnecessary casts for comparison
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22199

Reply via email to