unsigned foo(const unsigned x) { return (x / x); } double bar(const double x) { return (x / x); }
$ gcc -Wall -O2 -mregparm=3 -fomit-frame-pointer tmp.c -S foo: xorl %edx, %edx divl %eax ret bar: fldl 4(%esp) fdiv %st(0), %st ret I think optimizer should return 1 for both cases. -- Summary: missed div optimizations? Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC build triplet: i686-pld-linux GCC host triplet: i686-pld-linux GCC target triplet: i686-pld-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24333