From: Eric Botcazou Date: Fri, 25 Oct 2013 11:16:59 +0000 (+0000) Subject: re PR rtl-optimization/58831 (wrong code at -O2 and -O3 on x86_64-linux-gnu in 64... X-Git-Tag: releases/gcc-4.7.4~436 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d44365e5830db7778f1bdde455b76b30ace20d4c;p=thirdparty%2Fgcc.git re PR rtl-optimization/58831 (wrong code at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode) PR rtl-optimization/58831 * alias.c (init_alias_analysis): At the beginning of each iteration, set the reg_seen[N] flag if static_reg_base_value[N] is non-null. From-SVN: r204058 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9738fbc57ac4..6eb618560556 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-10-25 Eric Botcazou + + PR rtl-optimization/58831 + * alias.c (init_alias_analysis): At the beginning of each iteration, set + the reg_seen[N] flag if static_reg_base_value[N] is non-null. + 2013-10-25 Eric Botcazou * recog.c (search_ofs): New static variable moved from... diff --git a/gcc/alias.c b/gcc/alias.c index f20716d0dfff..7a56cda2de66 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -2810,16 +2810,13 @@ init_alias_analysis (void) /* Wipe the reg_seen array clean. */ memset (reg_seen, 0, maxreg); - /* Mark all hard registers which may contain an address. - The stack, frame and argument pointers may contain an address. - An argument register which can hold a Pmode value may contain - an address even if it is not in BASE_REGS. - - The address expression is VOIDmode for an argument and - Pmode for other registers. */ - - memcpy (new_reg_base_value, static_reg_base_value, - FIRST_PSEUDO_REGISTER * sizeof (rtx)); + /* Initialize the alias information for this pass. */ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + if (static_reg_base_value[i]) + { + new_reg_base_value[i] = static_reg_base_value[i]; + reg_seen[i] = 1; + } /* Walk the insns adding values to the new_reg_base_value array. */ for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa8d6b13f0aa..e04942b3f6c9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-10-25 Eric Botcazou + + * gcc.c-torture/execute/pr58831.c: New test. + 2013-10-16 Paolo Carlini PR c++/58633 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58831.c b/gcc/testsuite/gcc.c-torture/execute/pr58831.c new file mode 100644 index 000000000000..a40cd54d2229 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58831.c @@ -0,0 +1,40 @@ +#include + +int a, *b, c, d, f, **i, p, q, *r; +short o, j; + +static int __attribute__((noinline, noclone)) +fn1 (int *p1, int **p2) +{ + int **e = &b; + for (; p; p++) + *p1 = 1; + *e = *p2 = &d; + + assert (r); + + return c; +} + +static int ** __attribute__((noinline, noclone)) +fn2 (void) +{ + for (f = 0; f != 42; f++) + { + int *g[3] = {0, 0, 0}; + for (o = 0; o; o--) + for (; a > 1;) + { + int **h[1] = { &g[2] }; + } + } + return &r; +} + +int +main (void) +{ + i = fn2 (); + fn1 (b, i); + return 0; +}