[cfe-dev] one bit error

Ashish Gahlot via cfe-dev cfe-dev at lists.llvm.org
Fri Jan 20 21:32:38 PST 2017


sorry about that, I missed that detail. Thanks for correcting.

On Sat, Jan 21, 2017 at 10:59 AM, Alexey Sidorin <alexey.v.sidorin at ya.ru>
wrote:

> If you take a look at the generated code, you will see that clang uses
>         cmp     dword ptr [rbp - 12], 4000
>         jge     .LBB0_8
> which is equal (in C) to
>   if (i >= 4000)
>
> while gcc generates
>         cmp     DWORD PTR [rbp-8], 3999
>         jg      .L2
> which is equal to
>   if (i > 3999)
>
> I don't see any difference here. Why do you think this is an issue?
>
>
> 21.01.2017 07:46, Ashish Gahlot via cfe-dev пишет:
>
> 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.
>
> --
> Ashish Kumar Gahlot
> III year, UG
> Govt. Engg. College, Ajmer, India
>
>
> _______________________________________________
> cfe-dev mailing listcfe-dev at lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
>


-- 
Ashish Kumar Gahlot
III year, UG
Govt. Engg. College, Ajmer, India
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170121/58365be5/attachment.html>


More information about the cfe-dev mailing list