This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/79286] [7 Regression] wrong code at -O3 on x86_64-linux-gnu in 32-bit mode (but not in 64-bit mode)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79286

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Reducing the test-case bit more:

$ int a = 0, c = 0;
static int d[][8] = {};

int main ()
{
  int e;
  for (int b = 0; b < 4; b++)
    {
      __builtin_printf ("%d\n", b, e);
      while (a && c++)
        e = d[300000000000000000][0];
    }

  return 0;
}

Problem is that we segfault here:

   │0x8048448 <main+13>             push   %ebx
   │0x8048449 <main+14>             push   %ecx
   │0x804844a <main+15>             mov    $0x0,%ebx
   │0x804844f <main+20>             jmp    0x8048459 <main+30>
   │0x8048451 <main+22>             add    $0x1,%ebx
   │0x8048454 <main+25>             cmp    $0x4,%ebx
   │0x8048457 <main+28>             je     0x804849f <main+100>
   │0x8048459 <main+30>             sub    $0x4,%esp
  >│0x804845c <main+33>             pushl  0x1bc48534

which is I guess d[300000000000000000][0], which is a dead-code that is placed
before the printf call first time in 273r.ira:

...
(insn 8 7 9 3 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [1  S4 A32])
        (mem/u:SI (const:SI (plus:SI (symbol_ref:SI ("d") [flags 0x2] 
<var_decl 0x7fc764859f30 d>)
                    (const_int 331350016 [0x13c00000]))) [1 d+331350016 S4
A32])) "tc.c":9 58 {*pushsi2}
     (expr_list:REG_ARGS_SIZE (const_int 8 [0x8])
        (nil)))
(insn 9 8 10 3 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [1  S4 A32])
        (reg/v:SI 88 [ b ])) "tc.c":9 58 {*pushsi2}
     (expr_list:REG_ARGS_SIZE (const_int 12 [0xc])
        (nil)))
(insn 10 9 11 3 (set (mem/f:SI (pre_dec:SI (reg/f:SI 7 sp)) [2  S4 A32])
        (symbol_ref/f:SI ("*.LC0") [flags 0x2]  <var_decl 0x7fc76322eab0
*.LC0>)) "tc.c":9 58 {*pushsi2}
     (expr_list:REG_ARGS_SIZE (const_int 16 [0x10])
        (nil)))
(call_insn 11 10 12 3 (set (reg:SI 0 ax)
        (call (mem:QI (symbol_ref:SI ("printf") [flags 0x41]  <function_decl
0x7fc76318be00 __builtin_printf>) [0 __builtin_printf S1 A8])
            (const_int 16 [0x10]))) "tc.c":9 663 {*call_value}
     (expr_list:REG_UNUSED (reg:SI 0 ax)
        (nil))
    (nil))

That points to a different commit, I'll bisect that.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]