localhost tmp # cat 11.c
#include <stdio.h>
int main()
{
int i,x=99;
for(i=0;i<10000;i++)
x=(x+1)%32;
return 0;
}
localhost tmp # cat 22.c
#include <stdio.h>
int main()
{
unsigned int i,x=99;
for(i=0;i<10000;i++)
x=(x+1)%32;
return 0;
}
localhost tmp # gcc -S 11.c
localhost tmp # gcc -S 22.c
localhost tmp # diff -Nur 11.s 22.s
--- 11.s 2008-05-06 09:28:34.000000000 +0800
+++ 22.s 2008-05-06 09:28:46.000000000 +0800
@@ -1,4 +1,4 @@
- .file "11.c"
+ .file "22.c"
.text
.globl main
.type main, @function
@@ -14,20 +14,14 @@
movl $0, -12(%ebp)
jmp .L2
.L3:
- movl -8(%ebp), %edx
- incl %edx
- movl %edx, %eax
- sarl $31, %eax
- movl %eax, %ecx
- shrl $27, %ecx
- leal (%edx,%ecx), %eax
+ movl -8(%ebp), %eax
+ incl %eax
andl $31, %eax
- subl %ecx, %eax
movl %eax, -8(%ebp)
incl -12(%ebp)
.L2:
cmpl $9999, -12(%ebp)
- jle .L3
+ jbe .L3
movl $0, %eax
addl $16, %esp
popl %ecx
localhost tmp #
localhost tmp # gcc -O2 -S 22.c
localhost tmp # gcc -O2 -S 11.c
localhost tmp # diff -Nur 11.s 22.s
--- 11.s 2008-05-06 09:29:39.000000000 +0800
+++ 22.s 2008-05-06 09:29:34.000000000 +0800
@@ -1,4 +1,4 @@
- .file "11.c"
+ .file "22.c"
.text
.p2align 4,,15
.globl main
localhost tmp #