public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/52698] New: -maddress-mode=long doesn't work
@ 2012-03-24  6:52 hjl.tools at gmail dot com
  2012-03-24  9:54 ` [Bug target/52698] " ubizjak at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2012-03-24  6:52 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52698
           Summary: -maddress-mode=long doesn't work
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hjl.tools@gmail.com
                CC: ubizjak@gmail.com
            Target: x86-64


[hjl@gnu-mic-2 gcc]$ cat /tmp/x.c
extern void abort (void);
static __thread unsigned char foo [32]
  __attribute__ ((tls_model ("initial-exec"), aligned (sizeof (void *))));
void
test2 (void)
{
  unsigned int s;
  for (s = 0; s < sizeof (foo); ++s)
    {
      if (foo [s] != s)
 abort ();
      foo [s] = sizeof (foo) - s;
    }
}
[hjl@gnu-mic-2 gcc]$ ./xgcc -B./ -mx32 -O2  -S /tmp/x.c  -maddress-mode=long
/tmp/x.c: In function \u2018test2\u2019:
/tmp/x.c:14:1: error: insn does not satisfy its constraints:
(insn 52 78 53 5 (set (mem/j:QI (plus:DI (plus:DI (reg:DI 37 r8)
                    (reg:DI 38 r9))
                (reg:DI 2 cx [orig:98 D.1709 ] [98])) [0 foo S1 A8])
        (reg:QI 1 dx [100])) /tmp/x.c:12 66 {*movqi_internal}
     (nil))
/tmp/x.c:14:1: internal compiler error: in reload_cse_simplify_operands, at
postreload.c:403
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
[hjl@gnu-mic-2 gcc]$ ./xgcc -B./ -mx32 -O2  -S /tmp/x.c  -maddress-mode=short
[hjl@gnu-mic-2 gcc]$


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
@ 2012-03-24  9:54 ` ubizjak at gmail dot com
  2012-03-24 15:25 ` hjl.tools at gmail dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2012-03-24  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|x86-64                      |x32
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-03-24
         AssignedTo|unassigned at gcc dot       |ubizjak at gmail dot com
                   |gnu.org                     |
   Target Milestone|---                         |4.8.0
     Ever Confirmed|0                           |1

--- Comment #1 from Uros Bizjak <ubizjak at gmail dot com> 2012-03-24 08:42:04 UTC ---
Too many PLUS RTXes in address.


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
  2012-03-24  9:54 ` [Bug target/52698] " ubizjak at gmail dot com
@ 2012-03-24 15:25 ` hjl.tools at gmail dot com
  2012-03-24 17:14 ` hjl.tools at gmail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2012-03-24 15:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2012-03-24 15:20:06 UTC ---
Created attachment 26974
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26974
A patch

I am testing this patch with

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a21f2da..586be4b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3181,7 +3181,7 @@ ix86_option_override_internal (bool main_args_p)
          TARGET_64BIT ? "64" : "32");
     }
   else
-    ix86_pmode = TARGET_LP64 ? PMODE_DI : PMODE_SI;
+    ix86_pmode = TARGET_64BIT ? PMODE_DI : PMODE_SI;

   if (!global_options_set.x_ix86_abi)
     ix86_abi = DEFAULT_ABI;

I will run GCC testsuite as well as glibc build/test.  As I
indicated before, we can use

"mov{l}\t{%%fs:0, %k0|%k0, DWORD PTR fs:0}"

to load thread pointer, which is an unsigned integral value
with range from 0 to 0xffffffff into both SImode and DImode
register.  There is no need for zero-extend.


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
  2012-03-24  9:54 ` [Bug target/52698] " ubizjak at gmail dot com
  2012-03-24 15:25 ` hjl.tools at gmail dot com
@ 2012-03-24 17:14 ` hjl.tools at gmail dot com
  2012-03-25 20:09 ` ubizjak at gmail dot com
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2012-03-24 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2012-03-24 16:59:17 UTC ---
(In reply to comment #2)
> Created attachment 26974 [details]
> A patch
> 
> I am testing this patch with
> 

This patch passes GCC testsuite as well as glibc build/test
with both -maddress-mode=long and -maddress-mode=short.


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2012-03-24 17:14 ` hjl.tools at gmail dot com
@ 2012-03-25 20:09 ` ubizjak at gmail dot com
  2012-03-25 22:31 ` ubizjak at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2012-03-25 20:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Uros Bizjak <ubizjak at gmail dot com> 2012-03-25 19:00:10 UTC ---
(In reply to comment #0)
> [hjl@gnu-mic-2 gcc]$ cat /tmp/x.c
> extern void abort (void);
> static __thread unsigned char foo [32]
>   __attribute__ ((tls_model ("initial-exec"), aligned (sizeof (void *))));
> void
> test2 (void)
> {
>   unsigned int s;
>   for (s = 0; s < sizeof (foo); ++s)
>     {
>       if (foo [s] != s)
>  abort ();
>       foo [s] = sizeof (foo) - s;
>     }
> }
> [hjl@gnu-mic-2 gcc]$ ./xgcc -B./ -mx32 -O2  -S /tmp/x.c  -maddress-mode=long
> /tmp/x.c: In function \u2018test2\u2019:
> /tmp/x.c:14:1: error: insn does not satisfy its constraints:
> (insn 52 78 53 5 (set (mem/j:QI (plus:DI (plus:DI (reg:DI 37 r8)
>                     (reg:DI 38 r9))
>                 (reg:DI 2 cx [orig:98 D.1709 ] [98])) [0 foo S1 A8])
>         (reg:QI 1 dx [100])) /tmp/x.c:12 66 {*movqi_internal}
>      (nil))
> /tmp/x.c:14:1: internal compiler error: in reload_cse_simplify_operands, at
> postreload.c:403
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> [hjl@gnu-mic-2 gcc]$ ./xgcc -B./ -mx32 -O2  -S /tmp/x.c  -maddress-mode=short
> [hjl@gnu-mic-2 gcc]$

The problem is that reload generates invalid RTX address:

(plus:DI (plus:DI (zero_extend:DI (unspec:SI [
                    (const_int 0 [0])
                ] UNSPEC_TP))
        (reg:DI 97))
    (reg:DI 2 cx [orig:98 D.1709 ] [98]))

invalid in the sense, that we got pseudo in the strict mode. This is rejected
by ix86_legitimate_address_p, so reload uses bigger hammer and reloads all
components in registers:

Reloads for insn # 52
Reload 0: reload_in (DI) = (zero_extend:DI (unspec:SI [
                                                            (const_int 0 [0])
                                                        ] UNSPEC_TP))
        INDEX_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 0)
        reload_in_reg: (zero_extend:DI (unspec:SI [
                                                            (const_int 0 [0])
                                                        ] UNSPEC_TP))
        reload_reg_rtx: (reg:DI 37 r8)
Reload 1: reload_in (DI) = (reg:DI 97)
        GENERAL_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 0)
        reload_in_reg: (reg:DI 97)
        reload_reg_rtx: (reg:DI 38 r9)

Unfortunately, this creates invalid address with three-register addressing.

BTW: -mx32 just uncovered this problem, it can happen also for plain x86_32 or
x86_64 where segment registers are involved.


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2012-03-25 20:09 ` ubizjak at gmail dot com
@ 2012-03-25 22:31 ` ubizjak at gmail dot com
  2012-03-25 23:43 ` ubizjak at gmail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2012-03-25 22:31 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26974|0                           |1
        is obsolete|                            |

--- Comment #5 from Uros Bizjak <ubizjak at gmail dot com> 2012-03-25 22:28:23 UTC ---
Created attachment 26987
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26987
Patch that teaches x86 how to fix invalid reload address

Attached patch teaches x86 how to fix invalid reload address.

However, I'd say that there is a problem within reload pass, where reload
creates partially reloaded address, comprising strict and non-strict registers
(see comment #4). This address is passed to ix86_legitimate_address_p in strict
mode, and gets rejected.  Reload then bravely pushes every component into a
separate registers (3 in this case). This action creates even more invalid
address, also violating #define MAX_REGS_PER_ADDRESS 2.


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2012-03-25 22:31 ` ubizjak at gmail dot com
@ 2012-03-25 23:43 ` ubizjak at gmail dot com
  2012-03-26  3:26 ` hjl.tools at gmail dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2012-03-25 23:43 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ra
                 CC|                            |bernds at gcc dot gnu.org,
                   |                            |uweigand at gcc dot gnu.org

--- Comment #6 from Uros Bizjak <ubizjak at gmail dot com> 2012-03-25 22:32:30 UTC ---
CC reload experts for their opinion.


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (5 preceding siblings ...)
  2012-03-25 23:43 ` ubizjak at gmail dot com
@ 2012-03-26  3:26 ` hjl.tools at gmail dot com
  2012-03-27 15:40 ` uros at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2012-03-26  3:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> 2012-03-25 23:43:11 UTC ---
If

(plus:DI (plus:DI (zero_extend:DI (unspec:SI [
                    (const_int 0 [0])
                ] UNSPEC_TP))
        (reg:DI 97))
    (reg:DI 2 cx [orig:98 D.1709 ] [98]))

leads to reload problem, shouldn't we simply not generate

(zero_extend:DI (unspec:SI [(const_int 0 [0])] UNSPEC_TP))

to begin with, given that OS provides

(unspec:DI [(const_int 0 [0])] UNSPEC_TP)


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (6 preceding siblings ...)
  2012-03-26  3:26 ` hjl.tools at gmail dot com
@ 2012-03-27 15:40 ` uros at gcc dot gnu.org
  2012-03-29 19:19 ` uros at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uros at gcc dot gnu.org @ 2012-03-27 15:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from uros at gcc dot gnu.org 2012-03-27 15:36:41 UTC ---
Author: uros
Date: Tue Mar 27 15:36:34 2012
New Revision: 185883

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185883
Log:
    PR target/52698
    * config/i386/i386-protos.h (ix86_legitimize_reload_address):
    New prototype.
    * config/i386/i386.h (LEGITIMIZE_RELOAD_ADDRESS): New define.
    * config/i386/i386.c: Include reload.h.
    (ix86_legitimize_reload_address): New function.

testsuite/ChangeLog:

    PR target/52698
    * gcc.target/i386/pr52698.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr52698.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386-protos.h
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/i386.h
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (7 preceding siblings ...)
  2012-03-27 15:40 ` uros at gcc dot gnu.org
@ 2012-03-29 19:19 ` uros at gcc dot gnu.org
  2012-03-29 19:37 ` uros at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uros at gcc dot gnu.org @ 2012-03-29 19:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from uros at gcc dot gnu.org 2012-03-29 19:16:42 UTC ---
Author: uros
Date: Thu Mar 29 19:16:34 2012
New Revision: 185972

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185972
Log:
    Backported from mainline
    2012-03-27  Uros Bizjak  <ubizjak@gmail.com>

    PR target/52698
    * config/i386/i386-protos.h (ix86_legitimize_reload_address):
    New prototype.
    * config/i386/i386.h (LEGITIMIZE_RELOAD_ADDRESS): New define.
    * config/i386/i386.c: Include reload.h.
    (ix86_legitimize_reload_address): New function.


Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/i386/i386-protos.h
    branches/gcc-4_7-branch/gcc/config/i386/i386.c
    branches/gcc-4_7-branch/gcc/config/i386/i386.h


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (8 preceding siblings ...)
  2012-03-29 19:19 ` uros at gcc dot gnu.org
@ 2012-03-29 19:37 ` uros at gcc dot gnu.org
  2012-03-29 20:01 ` uros at gcc dot gnu.org
  2012-03-29 20:03 ` ubizjak at gmail dot com
  11 siblings, 0 replies; 13+ messages in thread
From: uros at gcc dot gnu.org @ 2012-03-29 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from uros at gcc dot gnu.org 2012-03-29 19:19:31 UTC ---
Author: uros
Date: Thu Mar 29 19:19:26 2012
New Revision: 185973

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185973
Log:
    Backported from mainline
    2012-03-27  Uros Bizjak  <ubizjak@gmail.com>

    PR target/52698
    * config/i386/i386-protos.h (ix86_legitimize_reload_address):
    New prototype.
    * config/i386/i386.h (LEGITIMIZE_RELOAD_ADDRESS): New define.
    * config/i386/i386.c: Include reload.h.
    (ix86_legitimize_reload_address): New function.


Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/i386-protos.h
    branches/gcc-4_6-branch/gcc/config/i386/i386.c
    branches/gcc-4_6-branch/gcc/config/i386/i386.h


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (9 preceding siblings ...)
  2012-03-29 19:37 ` uros at gcc dot gnu.org
@ 2012-03-29 20:01 ` uros at gcc dot gnu.org
  2012-03-29 20:03 ` ubizjak at gmail dot com
  11 siblings, 0 replies; 13+ messages in thread
From: uros at gcc dot gnu.org @ 2012-03-29 20:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from uros at gcc dot gnu.org 2012-03-29 19:59:40 UTC ---
Author: uros
Date: Thu Mar 29 19:59:36 2012
New Revision: 185975

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185975
Log:
    Backported from mainline
    2012-03-27  Uros Bizjak  <ubizjak@gmail.com>

    PR target/52698
    * config/i386/i386-protos.h (ix86_legitimize_reload_address):
    New prototype.
    * config/i386/i386.h (LEGITIMIZE_RELOAD_ADDRESS): New define.
    * config/i386/i386.c: Include reload.h.
    (ix86_legitimize_reload_address): New function.


Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/i386/i386-protos.h
    branches/gcc-4_5-branch/gcc/config/i386/i386.c
    branches/gcc-4_5-branch/gcc/config/i386/i386.h


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

* [Bug target/52698] -maddress-mode=long doesn't work
  2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
                   ` (10 preceding siblings ...)
  2012-03-29 20:01 ` uros at gcc dot gnu.org
@ 2012-03-29 20:03 ` ubizjak at gmail dot com
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2012-03-29 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.8.0                       |4.5.4

--- Comment #12 from Uros Bizjak <ubizjak at gmail dot com> 2012-03-29 20:00:57 UTC ---
Fixed everywhere.


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

end of thread, other threads:[~2012-03-29 20:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-24  6:52 [Bug target/52698] New: -maddress-mode=long doesn't work hjl.tools at gmail dot com
2012-03-24  9:54 ` [Bug target/52698] " ubizjak at gmail dot com
2012-03-24 15:25 ` hjl.tools at gmail dot com
2012-03-24 17:14 ` hjl.tools at gmail dot com
2012-03-25 20:09 ` ubizjak at gmail dot com
2012-03-25 22:31 ` ubizjak at gmail dot com
2012-03-25 23:43 ` ubizjak at gmail dot com
2012-03-26  3:26 ` hjl.tools at gmail dot com
2012-03-27 15:40 ` uros at gcc dot gnu.org
2012-03-29 19:19 ` uros at gcc dot gnu.org
2012-03-29 19:37 ` uros at gcc dot gnu.org
2012-03-29 20:01 ` uros at gcc dot gnu.org
2012-03-29 20:03 ` ubizjak at gmail dot com

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).