public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
@ 2012-01-18 17:24 aurelien.buhrig.gcc at gmail dot com
  2012-01-18 18:14 ` [Bug middle-end/51893] " aurelien.buhrig.gcc at gmail dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: aurelien.buhrig.gcc at gmail dot com @ 2012-01-18 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51893
           Summary: Wrong subword index computation in store_bit_field_1
                    on BIG_ENDIAN targets
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: aurelien.buhrig.gcc@gmail.com


Created attachment 26369
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26369
Patch

The subword index (wordnum) passed to operand_subword_force in
store_bit_field_1 is incorrect for BIG_ENDIAN targets when bitsize >
BITS_PER_WORD.

wordnum, which is used to get the subword of value, is
computed wrt the number of words needed by bitsize instead of the number of
words needed by the integer mode of the field, which is the mode used to
compute subwords.

For instance, for a 40bit field to be set by a DI reg (with HI words),
the offset of the LSWord of the DI reg should be 3, not 2 as currently
computed.

The attached patch seems to solve the issue. Tested on the C testsuite
without any regression (for my target only).

Note that this problem occurs on a "private" target (hardly reproducible).


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
@ 2012-01-18 18:14 ` aurelien.buhrig.gcc at gmail dot com
  2012-01-19  0:26 ` pinskia at gcc dot gnu.org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: aurelien.buhrig.gcc at gmail dot com @ 2012-01-18 18:14 UTC (permalink / raw)
  To: gcc-bugs

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

Aurelien Buhrig <aurelien.buhrig.gcc at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
  2012-01-18 18:14 ` [Bug middle-end/51893] " aurelien.buhrig.gcc at gmail dot com
@ 2012-01-19  0:26 ` pinskia at gcc dot gnu.org
  2012-01-19  0:57 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-19  0:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
  2012-01-18 18:14 ` [Bug middle-end/51893] " aurelien.buhrig.gcc at gmail dot com
  2012-01-19  0:26 ` pinskia at gcc dot gnu.org
@ 2012-01-19  0:57 ` pinskia at gcc dot gnu.org
  2012-01-19 10:45 ` rguenth at gcc dot gnu.org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-19  0:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-18 23:06:20 UTC ---
I see the issue, one place does it right and the other does not.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (2 preceding siblings ...)
  2012-01-19  0:57 ` pinskia at gcc dot gnu.org
@ 2012-01-19 10:45 ` rguenth at gcc dot gnu.org
  2012-01-19 10:52 ` ebotcazou at gcc dot gnu.org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-19 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-19
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-19 10:11:49 UTC ---
So, confirmed.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (3 preceding siblings ...)
  2012-01-19 10:45 ` rguenth at gcc dot gnu.org
@ 2012-01-19 10:52 ` ebotcazou at gcc dot gnu.org
  2012-01-20  9:36 ` aurelien.buhrig.gcc at gmail dot com
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-19 10:52 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-19 10:47:45 UTC ---
Please try the fix for PR middle-end/50325.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (4 preceding siblings ...)
  2012-01-19 10:52 ` ebotcazou at gcc dot gnu.org
@ 2012-01-20  9:36 ` aurelien.buhrig.gcc at gmail dot com
  2012-01-20 10:16 ` ebotcazou at gcc dot gnu.org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: aurelien.buhrig.gcc at gmail dot com @ 2012-01-20  9:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Aurelien Buhrig <aurelien.buhrig.gcc at gmail dot com> 2012-01-20 09:00:38 UTC ---
After modifying this patch for 4.6.1 this patch doesn't work (bitfld-3.c
testcase).

It doesn't affect the value subword offset computation (wordnum) when calling
operand_subword_force.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (5 preceding siblings ...)
  2012-01-20  9:36 ` aurelien.buhrig.gcc at gmail dot com
@ 2012-01-20 10:16 ` ebotcazou at gcc dot gnu.org
  2012-01-20 10:46 ` aurelien.buhrig.gcc at gmail dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-20 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-20 10:04:50 UTC ---
> After modifying this patch for 4.6.1 this patch doesn't work (bitfld-3.c
> testcase).

What do you mean exactly?  That gnat.dg/bitfld-3.c fails with the patch?


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (6 preceding siblings ...)
  2012-01-20 10:16 ` ebotcazou at gcc dot gnu.org
@ 2012-01-20 10:46 ` aurelien.buhrig.gcc at gmail dot com
  2012-01-20 11:33 ` ebotcazou at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: aurelien.buhrig.gcc at gmail dot com @ 2012-01-20 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Aurelien Buhrig <aurelien.buhrig.gcc at gmail dot com> 2012-01-20 10:32:22 UTC ---

(In reply to comment #5)
> > After modifying this patch for 4.6.1 this patch doesn't work (bitfld-3.c
> > testcase).
> 
> What do you mean exactly?  That gnat.dg/bitfld-3.c fails with the patch?

I mean the patch was likely done for 4.7, and I made very small adjustments to
enable patching on 4.6.1.

The testcase that fails is gcc.c-torture/execute/bitfld-3.c. Both with and
without (4.6.1 release) the patch. 
The patch I posted fixes the problem, but I don't know if it is general enough.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (7 preceding siblings ...)
  2012-01-20 10:46 ` aurelien.buhrig.gcc at gmail dot com
@ 2012-01-20 11:33 ` ebotcazou at gcc dot gnu.org
  2012-01-23  9:28 ` aurelien.buhrig.gcc at gmail dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-20 11:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-20 11:28:26 UTC ---
> The testcase that fails is gcc.c-torture/execute/bitfld-3.c. Both with and
> without (4.6.1 release) the patch. 
> The patch I posted fixes the problem, but I don't know if it is general enough.

OK, what are the values of the various parameters you have upon entering the
problematic block of code in store_bit_field_1?  Note that this code has been
working fine for years on 32-bit big-endian targets so this is unexpected.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (8 preceding siblings ...)
  2012-01-20 11:33 ` ebotcazou at gcc dot gnu.org
@ 2012-01-23  9:28 ` aurelien.buhrig.gcc at gmail dot com
  2012-03-20 16:26 ` aurelien.buhrig.gcc at gmail dot com
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: aurelien.buhrig.gcc at gmail dot com @ 2012-01-23  9:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Aurelien Buhrig <aurelien.buhrig.gcc at gmail dot com> 2012-01-23 08:27:22 UTC ---
It seems the problem occurs with big endian targets when value is at least 4
times bigger than a word.
Example:
bitsize=40, value = reg:DI sub words-->HI. So wordnum = 3.

The for loop should start from LSWord to bitsize MSWord (wordnum).
So:
subword 3 from value, and calls  store_bit_fields_1 with bitsize <=
BITS_PER_WORD
then subword 2,
then subword 1
And subword 0 from value should be ignored.

Currently, the loop does not begins with subword 3, but with subword
"wordnum-1" which is 2. It is not the LSword of value, and the value stored in
the bitfield is (value << BITS_PER_WORD).


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (9 preceding siblings ...)
  2012-01-23  9:28 ` aurelien.buhrig.gcc at gmail dot com
@ 2012-03-20 16:26 ` aurelien.buhrig.gcc at gmail dot com
  2012-03-20 23:00 ` ebotcazou at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: aurelien.buhrig.gcc at gmail dot com @ 2012-03-20 16:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Aurelien Buhrig <aurelien.buhrig.gcc at gmail dot com> 2012-03-20 16:22:52 UTC ---
Do you need additional information about this bug?
Any comment about the provided patch?


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (10 preceding siblings ...)
  2012-03-20 16:26 ` aurelien.buhrig.gcc at gmail dot com
@ 2012-03-20 23:00 ` ebotcazou at gcc dot gnu.org
  2012-03-27 20:58 ` ebotcazou at gcc dot gnu.org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-03-20 23:00 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-03-20 22:03:27 UTC ---
> Do you need additional information about this bug?
> Any comment about the provided patch?

No, I think the patch is correct.  Please post it on gcc-patches@.


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (11 preceding siblings ...)
  2012-03-20 23:00 ` ebotcazou at gcc dot gnu.org
@ 2012-03-27 20:58 ` ebotcazou at gcc dot gnu.org
  2012-03-28  9:11 ` ebotcazou at gcc dot gnu.org
  2012-03-28  9:14 ` ebotcazou at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-03-27 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-03-27 20:50:21 UTC ---
Author: ebotcazou
Date: Tue Mar 27 20:50:16 2012
New Revision: 185897

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185897
Log:
    PR middle-end/51893
    * expmed.c (store_bit_field_1): Fix wordnum value for big-endian
    targets.

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


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (12 preceding siblings ...)
  2012-03-27 20:58 ` ebotcazou at gcc dot gnu.org
@ 2012-03-28  9:11 ` ebotcazou at gcc dot gnu.org
  2012-03-28  9:14 ` ebotcazou at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-03-28  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-03-28 09:06:30 UTC ---
Author: ebotcazou
Date: Wed Mar 28 09:06:03 2012
New Revision: 185909

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185909
Log:
    PR middle-end/51893
    * expmed.c (store_bit_field_1): Fix wordnum value for big-endian
    targets.

Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/expmed.c


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

* [Bug middle-end/51893] Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets
  2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
                   ` (13 preceding siblings ...)
  2012-03-28  9:11 ` ebotcazou at gcc dot gnu.org
@ 2012-03-28  9:14 ` ebotcazou at gcc dot gnu.org
  14 siblings, 0 replies; 16+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-03-28  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.1

--- Comment #13 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-03-28 09:10:35 UTC ---
Fixed in the 4.7.x series.  Thanks for the bug report and the patch.


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

end of thread, other threads:[~2012-03-28  9:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18 17:24 [Bug middle-end/51893] New: Wrong subword index computation in store_bit_field_1 on BIG_ENDIAN targets aurelien.buhrig.gcc at gmail dot com
2012-01-18 18:14 ` [Bug middle-end/51893] " aurelien.buhrig.gcc at gmail dot com
2012-01-19  0:26 ` pinskia at gcc dot gnu.org
2012-01-19  0:57 ` pinskia at gcc dot gnu.org
2012-01-19 10:45 ` rguenth at gcc dot gnu.org
2012-01-19 10:52 ` ebotcazou at gcc dot gnu.org
2012-01-20  9:36 ` aurelien.buhrig.gcc at gmail dot com
2012-01-20 10:16 ` ebotcazou at gcc dot gnu.org
2012-01-20 10:46 ` aurelien.buhrig.gcc at gmail dot com
2012-01-20 11:33 ` ebotcazou at gcc dot gnu.org
2012-01-23  9:28 ` aurelien.buhrig.gcc at gmail dot com
2012-03-20 16:26 ` aurelien.buhrig.gcc at gmail dot com
2012-03-20 23:00 ` ebotcazou at gcc dot gnu.org
2012-03-27 20:58 ` ebotcazou at gcc dot gnu.org
2012-03-28  9:11 ` ebotcazou at gcc dot gnu.org
2012-03-28  9:14 ` ebotcazou 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).