public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/54974] New: [ARM] Incorrect placement of constant pools
@ 2012-10-18 12:58 mans at mansr dot com
  2012-10-18 13:01 ` [Bug target/54974] " mans at mansr dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: mans at mansr dot com @ 2012-10-18 12:58 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54974
           Summary: [ARM] Incorrect placement of constant pools
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mans@mansr.com


Created attachment 28483
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28483
Test case

If the following conditions are true, a constant pool is placed too far from an
LDR instruction accessing it:

- Compiling to Thumb2.
- There is no unconditional branch within 4k of the LDR instruction.
- At least one of:
  * The LDR instruction is not at a 4-byte aligned address.
  * There is an instruction boundary 4094 bytes from the value of PC
    at the LDR.

The problem here is twofold:

1. The base address of a PC-relative LDR in Thumb2 is the address of the
   instruction plus 4, rounded down to a multiple of 4.  The calculation
   for the valid range fails to take this rounding into account.

2. The constant pool is (rightly) 4-byte aligned.  When scanning the
   instructions for a suitable location, the possible need for padding
   is not considered.

The problem can be seen by compiling the attached preprocessed source using
flags "-mthumb -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -O0 -fPIC".


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

* [Bug target/54974] [ARM] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
@ 2012-10-18 13:01 ` mans at mansr dot com
  2012-10-18 13:20 ` [Bug target/54974] [4.8 Regression] " doko at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mans at mansr dot com @ 2012-10-18 13:01 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Mans Rullgard <mans at mansr dot com> 2012-10-18 13:00:48 UTC ---
Created attachment 28484
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28484
Hack patch

This hack patch validates the analysis.  A proper fix probably looks different.


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

* [Bug target/54974] [4.8 Regression] [ARM] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
  2012-10-18 13:01 ` [Bug target/54974] " mans at mansr dot com
@ 2012-10-18 13:20 ` doko at gcc dot gnu.org
  2012-10-18 13:23 ` mikpe at it dot uu.se
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: doko at gcc dot gnu.org @ 2012-10-18 13:20 UTC (permalink / raw)
  To: gcc-bugs


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

Matthias Klose <doko at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Target|                            |arm-linux-gnueabi
      Known to work|                            |4.7.2
            Summary|[ARM] Incorrect placement   |[4.8 Regression] [ARM]
                   |of constant pools           |Incorrect placement of
                   |                            |constant pools
      Known to fail|                            |4.8.0

--- Comment #2 from Matthias Klose <doko at gcc dot gnu.org> 2012-10-18 13:20:19 UTC ---
works with 4.7, fails with trunk


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

* [Bug target/54974] [4.8 Regression] [ARM] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
  2012-10-18 13:01 ` [Bug target/54974] " mans at mansr dot com
  2012-10-18 13:20 ` [Bug target/54974] [4.8 Regression] " doko at gcc dot gnu.org
@ 2012-10-18 13:23 ` mikpe at it dot uu.se
  2012-10-18 18:09 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mikpe at it dot uu.se @ 2012-10-18 13:23 UTC (permalink / raw)
  To: gcc-bugs


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

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> 2012-10-18 13:23:13 UTC ---
Also works with gcc-4.6.


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

* [Bug target/54974] [4.8 Regression] [ARM] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (2 preceding siblings ...)
  2012-10-18 13:23 ` mikpe at it dot uu.se
@ 2012-10-18 18:09 ` pinskia at gcc dot gnu.org
  2012-10-18 19:43 ` mikpe at it dot uu.se
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-10-18 18:09 UTC (permalink / raw)
  To: gcc-bugs


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
   Target Milestone|---                         |4.8.0


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

* [Bug target/54974] [4.8 Regression] [ARM] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (3 preceding siblings ...)
  2012-10-18 18:09 ` pinskia at gcc dot gnu.org
@ 2012-10-18 19:43 ` mikpe at it dot uu.se
  2012-10-19 12:24 ` doko at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mikpe at it dot uu.se @ 2012-10-18 19:43 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Mikael Pettersson <mikpe at it dot uu.se> 2012-10-18 19:43:02 UTC ---
The test case started failing with r189790:
http://gcc.gnu.org/ml/gcc-cvs/2012-07/msg00695.html

That patch merely enabled insn splitting at -O0, so I suspect it exposed a
latent problem in the back-end, consistent with Måns' analysis.


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

* [Bug target/54974] [4.8 Regression] [ARM] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (4 preceding siblings ...)
  2012-10-18 19:43 ` mikpe at it dot uu.se
@ 2012-10-19 12:24 ` doko at gcc dot gnu.org
  2012-11-28  3:04 ` [Bug target/54974] [4.7/4.8 Regression] [ARM] [thumb] " ramana at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: doko at gcc dot gnu.org @ 2012-10-19 12:24 UTC (permalink / raw)
  To: gcc-bugs


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

Matthias Klose <doko at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|4.7.2                       |4.6.3
      Known to fail|                            |4.7.2

--- Comment #5 from Matthias Klose <doko at gcc dot gnu.org> 2012-10-19 12:23:57 UTC ---
this patch is now on the 4.7 branch too.


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

* [Bug target/54974] [4.7/4.8 Regression] [ARM] [thumb] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (5 preceding siblings ...)
  2012-10-19 12:24 ` doko at gcc dot gnu.org
@ 2012-11-28  3:04 ` ramana at gcc dot gnu.org
  2012-11-29 10:02 ` mgretton at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-11-28  3:04 UTC (permalink / raw)
  To: gcc-bugs


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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-11-28
                 CC|                            |ramana at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |mgretton at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #6 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-11-28 03:03:50 UTC ---
http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01825.html

Patch posted here.


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

* [Bug target/54974] [4.7/4.8 Regression] [ARM] [thumb] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (6 preceding siblings ...)
  2012-11-28  3:04 ` [Bug target/54974] [4.7/4.8 Regression] [ARM] [thumb] " ramana at gcc dot gnu.org
@ 2012-11-29 10:02 ` mgretton at gcc dot gnu.org
  2012-12-03 15:58 ` [Bug target/54974] [4.7 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mgretton at gcc dot gnu.org @ 2012-11-29 10:02 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from mgretton at gcc dot gnu.org 2012-11-29 10:02:22 UTC ---
Author: mgretton
Date: Thu Nov 29 10:02:16 2012
New Revision: 193930

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193930
Log:
    PR target/54974
    * config/arm/arm.md (thumb2_pool_range, pool_range): Add comment on
    Thumb pool ranges.
    (thumb1_extendhisi2): Reduce Thumb pool range.
    (arm_movdi): Likewise.
    (thumb1_movdi_insn): Likewise.
    (thumb1_movsi_insn): Likewise.
    (pic_load_addr_unified): Likewise.
    (pic_load_addr_32bit): Likewise.
    (pic_load_addr_thumb1): Likewise.
    (thumb1_movhf): Likewise.
    (arm_movsf_soft_insn): Likewise.
    (thumb1_movsf_soft_insn): Likewise.
    (movdf_soft_insn): Likewise.
    (thumb1_movdf_soft_insn): Likewise.
    * config/arm/neon.md (*neon_mov<mode>): Likewise.
    (*neon_mov<mode>): Likwise.
    * config/arm/thumb2.md: (*thumb2_movsi_insn): Likewise.
    (*thumb2_movhi_insn): Likewise.
    (*thumb2_extendqisi_v6): Likewise.
    (*thumb2_zero_extendqisi_v6): Likewise.
    (*thumb2_zero_extendqisi2_v6): Likewise.
    * config/arm/vfp.md: (*thumb2_movsi_vfp): Likewise.
    (*movdi_vfp): Likewise.
    (*movdi_vfp_cortexa8): Likewise.
    (*thumb2_movsf_vfp): Likewise.
    (*thumb2_movdf_vfp): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.md
    trunk/gcc/config/arm/neon.md
    trunk/gcc/config/arm/thumb2.md
    trunk/gcc/config/arm/vfp.md


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

* [Bug target/54974] [4.7 Regression] [ARM] [thumb] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (7 preceding siblings ...)
  2012-11-29 10:02 ` mgretton at gcc dot gnu.org
@ 2012-12-03 15:58 ` rguenth at gcc dot gnu.org
  2012-12-11 17:36 ` ramana at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-03 15:58 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
      Known to work|                            |4.8.0
   Target Milestone|4.8.0                       |4.7.3
            Summary|[4.7/4.8 Regression] [ARM]  |[4.7 Regression] [ARM]
                   |[thumb] Incorrect placement |[thumb] Incorrect placement
                   |of constant pools           |of constant pools
      Known to fail|4.8.0                       |

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-03 15:58:20 UTC ---
Fixed on the trunk I suppose.


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

* [Bug target/54974] [4.7 Regression] [ARM] [thumb] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (8 preceding siblings ...)
  2012-12-03 15:58 ` [Bug target/54974] [4.7 " rguenth at gcc dot gnu.org
@ 2012-12-11 17:36 ` ramana at gcc dot gnu.org
  2013-04-11  7:59 ` rguenth at gcc dot gnu.org
  2014-06-12 13:19 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-12-11 17:36 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #9 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-12-11 17:36:34 UTC ---
Matt, 

Are you planning on backporting this to 4.7 ? 

regards
Ramana


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

* [Bug target/54974] [4.7 Regression] [ARM] [thumb] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (9 preceding siblings ...)
  2012-12-11 17:36 ` ramana at gcc dot gnu.org
@ 2013-04-11  7:59 ` rguenth at gcc dot gnu.org
  2014-06-12 13:19 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-11  7:59 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.3                       |4.7.4

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-11 07:59:05 UTC ---
GCC 4.7.3 is being released, adjusting target milestone.


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

* [Bug target/54974] [4.7 Regression] [ARM] [thumb] Incorrect placement of constant pools
  2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
                   ` (10 preceding siblings ...)
  2013-04-11  7:59 ` rguenth at gcc dot gnu.org
@ 2014-06-12 13:19 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.7.4                       |4.8.0
      Known to fail|4.7.2                       |4.7.4

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.8.0.


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

end of thread, other threads:[~2014-06-12 13:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18 12:58 [Bug target/54974] New: [ARM] Incorrect placement of constant pools mans at mansr dot com
2012-10-18 13:01 ` [Bug target/54974] " mans at mansr dot com
2012-10-18 13:20 ` [Bug target/54974] [4.8 Regression] " doko at gcc dot gnu.org
2012-10-18 13:23 ` mikpe at it dot uu.se
2012-10-18 18:09 ` pinskia at gcc dot gnu.org
2012-10-18 19:43 ` mikpe at it dot uu.se
2012-10-19 12:24 ` doko at gcc dot gnu.org
2012-11-28  3:04 ` [Bug target/54974] [4.7/4.8 Regression] [ARM] [thumb] " ramana at gcc dot gnu.org
2012-11-29 10:02 ` mgretton at gcc dot gnu.org
2012-12-03 15:58 ` [Bug target/54974] [4.7 " rguenth at gcc dot gnu.org
2012-12-11 17:36 ` ramana at gcc dot gnu.org
2013-04-11  7:59 ` rguenth at gcc dot gnu.org
2014-06-12 13:19 ` rguenth at gcc dot gnu.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).