public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/44790]  New: Bootstrap fails after MEM-REF merge
@ 2010-07-02 18:53 sje at cup dot hp dot com
  2010-07-02 19:49 ` [Bug middle-end/44790] " sje at cup dot hp dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: sje at cup dot hp dot com @ 2010-07-02 18:53 UTC (permalink / raw)
  To: gcc-bugs

GCC fails to bootstrap on ia64-hp-hpux11.23 after r161655.  Building without
bootstrap and running the testsuite shows that tests are failing in 32 bit mode
but not 64 bit mode so the problem is probably ia64's unique method of
extending pointers in 32 bit mode  Most of the failing tests involve va_args.

Here is a cutdown test that fails:

f (int n, ...)
{
  long x;
  int i;

  __builtin_va_list ap;
  __builtin_va_start(ap,n);
  x = __builtin_va_arg(ap,long);
  if (x != 123)
      abort();
  __builtin_va_end(ap);
}

main ()
{
  f (3, (long) 123);
  exit(0);
}


-- 
           Summary: Bootstrap fails after MEM-REF merge
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sje at cup dot hp dot com
 GCC build triplet: ia64-hp-hpux11.23
  GCC host triplet: ia64-hp-hpux11.23
GCC target triplet: ia64-hp-hpux11.23


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
@ 2010-07-02 19:49 ` sje at cup dot hp dot com
  2010-07-03 11:17 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sje at cup dot hp dot com @ 2010-07-02 19:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from sje at cup dot hp dot com  2010-07-02 19:49 -------
This may be related to &x + CST folding.  The bug only happens at -O1 or above.
I think I forgot to mention that in the original bug report.
When I look at the expand dump and the comparision to 123 I see:


(insn 17 16 18 3 x.c:8 (set (reg:DI 348)
        (zero_extend:DI (subreg/s/v:SI (reg/v/f:DI 339 [ ap+-4 ]) 4))) -1
(nil))

(insn 18 17 19 3 x.c:8 (set (reg/f:DI 347)
        (plus:DI (reg:DI 348)
            (const_int 4 [0x4]))) -1 (nil))

(insn 19 18 20 3 x.c:9 (set (reg:SI 349)
        (mem:SI (reg/f:DI 347) [0 MEM[(int *)ap_1 + 4B]+0 S4 A32])) -1 (nil))

(insn 20 19 21 3 x.c:9 (set (reg:BI 350)
        (eq:BI (reg:SI 349)
            (const_int 123 [0x7b]))) -1 (nil))

Instruction 17, where we set r348 to zero_extend of r339 looks wrong.  We
need to do a pointer extend here, I.e. (unspec 24) go generate an addp4.
r349 is not a valid pointer after instruction 17 and this generates the fault.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
  2010-07-02 19:49 ` [Bug middle-end/44790] " sje at cup dot hp dot com
@ 2010-07-03 11:17 ` rguenth at gcc dot gnu dot org
  2010-07-06 14:26 ` [Bug middle-end/44790] [4.6 Regression] " rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-03 11:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-07-03 11:17 -------
The code in question is likely expr.c:8830 ff:

        address_mode = targetm.addr_space.address_mode (as);
        op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, address_mode,
                           EXPAND_NORMAL);
        if (!integer_zerop (TREE_OPERAND (exp, 1)))
          {
            rtx off;
            off = immed_double_int_const (mem_ref_offset (exp), address_mode);
            op0 = simplify_gen_binary (PLUS, address_mode, op0, off);
          }
        op0 = memory_address_addr_space (mode, op0, as);
        temp = gen_rtx_MEM (mode, op0);

I see that POINTER_PLUS_EXPR would end up doing

;; ap_2 = ap_1 + 8;

(insn 10 9 11 t.i:8 (set (reg:SI 345)
        (plus:SI (subreg/s/v:SI (reg/v/f:DI 339 [ ap+-4 ]) 4)
            (const_int 8 [0x8]))) -1 (nil))

(insn 11 10 0 t.i:8 (set (reg/v/f:DI 340 [ ap+-4 ])
        (unspec:DI [
                (reg:SI 345)
            ] 24)) -1 (nil))

thus appearantly the pointer mode is DI but offsets are 32bit(?!)

OTOH doing

Index: expr.c
===================================================================
--- expr.c      (revision 161771)
+++ expr.c      (working copy)
@@ -8817,14 +8817,12 @@ expand_expr_real_1 (tree exp, rtx target
              }
          }
        address_mode = targetm.addr_space.address_mode (as);
-       op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, address_mode,
-                          EXPAND_NORMAL);
+       base = TREE_OPERAND (exp, 0);
        if (!integer_zerop (TREE_OPERAND (exp, 1)))
-         {
-           rtx off;
-           off = immed_double_int_const (mem_ref_offset (exp), address_mode);
-           op0 = simplify_gen_binary (PLUS, address_mode, op0, off);
-         }
+         base = build2 (POINTER_PLUS_EXPR, TREE_TYPE (base),
+                        base, double_int_to_tree (sizetype,
+                                                  mem_ref_offset (exp)));
+       op0 = expand_expr (base, NULL_RTX, address_mode, EXPAND_SUM);
        op0 = memory_address_addr_space (mode, op0, as);
        temp = gen_rtx_MEM (mode, op0);
        set_mem_attributes (temp, exp, 0);

generates

(insn 13 12 14 t.i:8 (set (reg:DI 346)
        (reg/v/f:DI 339 [ ap+-4 ])) -1 (nil))

(insn 14 13 15 t.i:8 (set (reg/f:DI 347)
        (plus:DI (reg/v/f:DI 339 [ ap+-4 ])
            (const_int 4 [0x4]))) -1 (nil))

(insn 15 14 16 t.i:9 (set (reg:SI 348)
        (mem:SI (reg/f:DI 347) [0 MEM[(long int *)ap_1 + 4B]+0 S4 A32])) -1
(nil))

which doesn't use an UNSPEC either.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
  2010-07-02 19:49 ` [Bug middle-end/44790] " sje at cup dot hp dot com
  2010-07-03 11:17 ` rguenth at gcc dot gnu dot org
@ 2010-07-06 14:26 ` rguenth at gcc dot gnu dot org
  2010-07-06 16:44 ` sje at cup dot hp dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-06 14:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Bootstrap fails after MEM-  |[4.6 Regression] Bootstrap
                   |REF merge                   |fails after MEM-REF merge
   Target Milestone|---                         |4.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
                   ` (2 preceding siblings ...)
  2010-07-06 14:26 ` [Bug middle-end/44790] [4.6 Regression] " rguenth at gcc dot gnu dot org
@ 2010-07-06 16:44 ` sje at cup dot hp dot com
  2010-07-06 22:56 ` sje at cup dot hp dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sje at cup dot hp dot com @ 2010-07-06 16:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sje at cup dot hp dot com  2010-07-06 16:44 -------
The neccessary UNSPEC seems to be there if you trace the instructions back
far enough.  I tried it on my test case and it worked.  I am now testing the
patch on ToT to see if I can bootstrap.  I also have to turn off partial
inlining to get bootstrap to work on ia64-hp-hpux11.23.  I tweaked the patch
for ToT there are a bunch of changes to expr.c including setting base so the
patch I am currently testing with r161861 looks like this:

Index: expr.c
===================================================================
--- expr.c      (revision 161861)
+++ expr.c      (working copy)
@@ -8777,13 +8777,11 @@ expand_expr_real_1 (tree exp, rtx target
          base = build2 (BIT_AND_EXPR, TREE_TYPE (base),
                         gimple_assign_rhs1 (def_stmt),
                         gimple_assign_rhs2 (def_stmt));
-       op0 = expand_expr (base, NULL_RTX, address_mode, EXPAND_NORMAL);
        if (!integer_zerop (TREE_OPERAND (exp, 1)))
-         {
-           rtx off;
-           off = immed_double_int_const (mem_ref_offset (exp), address_mode);
-           op0 = simplify_gen_binary (PLUS, address_mode, op0, off);
-         }
+         base = build2 (POINTER_PLUS_EXPR, TREE_TYPE (base),
+                        base, double_int_to_tree (sizetype,
+                                                  mem_ref_offset (exp)));
+       op0 = expand_expr (base, NULL_RTX, address_mode, EXPAND_SUM);
        op0 = memory_address_addr_space (mode, op0, as);
        temp = gen_rtx_MEM (mode, op0);
        set_mem_attributes (temp, exp, 0);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
                   ` (3 preceding siblings ...)
  2010-07-06 16:44 ` sje at cup dot hp dot com
@ 2010-07-06 22:56 ` sje at cup dot hp dot com
  2010-07-07  8:35 ` rguenther at suse dot de
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sje at cup dot hp dot com @ 2010-07-06 22:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from sje at cup dot hp dot com  2010-07-06 22:56 -------
I successfully bootstrapped ToT (after setting flag_partial_inlining to 0 to
work around pr44716) using the patch.  Testing also looked good, there are some
new failures but they are all either new tests that may have never worked on
this platform or tests that are also failing on other platforms.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
                   ` (4 preceding siblings ...)
  2010-07-06 22:56 ` sje at cup dot hp dot com
@ 2010-07-07  8:35 ` rguenther at suse dot de
  2010-07-07 12:44 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenther at suse dot de @ 2010-07-07  8:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenther at suse dot de  2010-07-07 08:35 -------
Subject: Re:  [4.6 Regression] Bootstrap fails after
 MEM-REF merge

On Tue, 6 Jul 2010, sje at cup dot hp dot com wrote:

> ------- Comment #4 from sje at cup dot hp dot com  2010-07-06 22:56 -------
> I successfully bootstrapped ToT (after setting flag_partial_inlining to 0 to
> work around pr44716) using the patch.  Testing also looked good, there are some
> new failures but they are all either new tests that may have never worked on
> this platform or tests that are also failing on other platforms.

Ok.  I'll bootstrap & test the patch on x86_64-linux and apply it.

Thanks,
Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
                   ` (5 preceding siblings ...)
  2010-07-07  8:35 ` rguenther at suse dot de
@ 2010-07-07 12:44 ` rguenth at gcc dot gnu dot org
  2010-07-07 13:04 ` rguenth at gcc dot gnu dot org
  2010-07-28  7:45 ` ebotcazou at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-07 12:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2010-07-07 12:43 -------
Subject: Bug 44790

Author: rguenth
Date: Wed Jul  7 12:43:38 2010
New Revision: 161907

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161907
Log:
2010-07-07  Richard Guenther  <rguenther@suse.de>

        PR middle-end/44790
        * expr.c (expand_expr_real_1): Go the POINTER_PLUS_EXPR path
        for expanding the constant offset for MEM_REFs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
                   ` (6 preceding siblings ...)
  2010-07-07 12:44 ` rguenth at gcc dot gnu dot org
@ 2010-07-07 13:04 ` rguenth at gcc dot gnu dot org
  2010-07-28  7:45 ` ebotcazou at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-07 13:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2010-07-07 13:04 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/44790] [4.6 Regression] Bootstrap fails after MEM-REF merge
  2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
                   ` (7 preceding siblings ...)
  2010-07-07 13:04 ` rguenth at gcc dot gnu dot org
@ 2010-07-28  7:45 ` ebotcazou at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-07-28  7:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ebotcazou at gcc dot gnu dot org  2010-07-28 07:44 -------
Subject: Bug 44790

Author: ebotcazou
Date: Wed Jul 28 07:44:34 2010
New Revision: 162618

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162618
Log:
        PR middle-end/44790
        PR middle-end/44993
        * expr.c (expand_expr_real_1) <MEM_REF>: Revert latest change.  Make
        sure the base has address_mode before adding the offset.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44790


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-07-28  7:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-02 18:53 [Bug middle-end/44790] New: Bootstrap fails after MEM-REF merge sje at cup dot hp dot com
2010-07-02 19:49 ` [Bug middle-end/44790] " sje at cup dot hp dot com
2010-07-03 11:17 ` rguenth at gcc dot gnu dot org
2010-07-06 14:26 ` [Bug middle-end/44790] [4.6 Regression] " rguenth at gcc dot gnu dot org
2010-07-06 16:44 ` sje at cup dot hp dot com
2010-07-06 22:56 ` sje at cup dot hp dot com
2010-07-07  8:35 ` rguenther at suse dot de
2010-07-07 12:44 ` rguenth at gcc dot gnu dot org
2010-07-07 13:04 ` rguenth at gcc dot gnu dot org
2010-07-28  7:45 ` ebotcazou at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).