[cfe-dev] one bit error

Mehdi Amini via cfe-dev cfe-dev at lists.llvm.org
Fri Jan 20 21:26:43 PST 2017


> On Jan 20, 2017, at 8:46 PM, Ashish Gahlot via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> This is my first try on mailing list. Please correct if I am wrong.
> On compiling this program using clang 3.9.1
> 
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main () {
>   int i,j;
>   static int x[4000][4000];
>   for (j = 0; j < 4000; j++) {
>      for (i = 0; i < 4000; i++) {
>        x[j][i] = i + j; }
>    }
> }
> got compiled to 
> 
>         mov     dword ptr [rbp - 4], 0
>         mov     dword ptr [rbp - 12], 0
> .LBB0_1:                                # =>This Loop Header: Depth=1
>         cmp     dword ptr [rbp - 12], 4000
>         jge     .LBB0_8
>         mov     dword ptr [rbp - 8], 0
> .LBB0_3:                                #   Parent Loop BB0_1 Depth=1
>         cmp     dword ptr [rbp - 8], 4000
> 
> while gcc 7 gives this 
> 
>         mov     DWORD PTR [rbp-8], 0
> .L5:
>         cmp     DWORD PTR [rbp-8], 3999
>         jg      .L2
>         mov     DWORD PTR [rbp-4], 0
> .L4:
>         cmp     DWORD PTR [rbp-4], 3999
>         jg      .L3
> 
> I think it should be 3999.

What makes you think there is an issue? Do you observe an actual issue when you run your program? 
(Did you notice that clang uses jge while gcc uses jg?)

— 
Mehdi




More information about the cfe-dev mailing list