This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Mined out of comp.std.c...
- From: "Rupert Wood" <me at rupey dot net>
- To: "'Zack Weinberg'" <zack at codesourcery dot com>
- Cc: "'Jan Hubicka'" <jh at suse dot cz>,<gcc at gcc dot gnu dot org>
- Date: Thu, 25 Apr 2002 09:38:58 +0100
- Subject: RE: Mined out of comp.std.c...
Zack Weinberg wrote:
> static int int_max (int a, int b) {
> int d = (b - a);
> return (b - d) & (d >> (CHAR_BIT*sizeof(int) - 1));
> }
Maybe I need more coffee, but isn't (b-d) == a?
> 8: 89 c2 mov %eax,%edx
> a: 29 ca sub %ecx,%edx
> c: 29 d0 sub %edx,%eax
> e: c1 fa 1f sar $0x1f,%edx
> 11: 21 d0 and %edx,%eax
so rather
subl %eax, %ecx
sarl $31, %ecx
andl %ecx, %eax
Rup.