Re: have a look at this proggie, please.

Perry Harrington (pedward@sun4.apsoft.com)
Wed, 18 Nov 1998 17:31:59 -0800 (PST)


Assembled differences:

One is immediate, the other is on the stack.

GCC optimized this, even with no optimizations.

GCC warned me that MININT / -1 immediate was an integer
overflow and didn't generate any code.

This just looks like an overflow which is trowing a trap
handler. I don't know what cltd is, but I suspect it clears
a flag.

a = -4(%ebp) == MININT == -2147483648
b = -8(%ebp) == -1

stack: c = a / b;
- movl -4(%ebp),%ecx
- movl %ecx,%eax
- cltd
- idivl -8(%ebp)

immediate: c = a / -1;
+ movl -4(%ebp),%edx
+ movl %edx,%eax
+ negl %eax
movl %eax,-12(%ebp)

> int a = -MAXINT-1, b = -1, c = a*b;
>
> c = a / b;
>
> /*
> * Regards,
> * Tigran
> */

--Perry

-- 
Perry Harrington       Linux rules all OSes.    APSoft      ()
email: perry@apsoft.com 			Think Blue. /\

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/