public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets
@ 2014-08-12 2:14 thopre01 at gcc dot gnu.org
2014-08-12 2:16 ` [Bug middle-end/62103] " thopre01 at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-08-12 2:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
Bug ID: 62103
Summary: Incorrect folding of bitfield in a union on big endian
targets
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: thopre01 at gcc dot gnu.org
Folding of bitfield in a union is incorrect on big endian targets. Consider the
testcase given in attachment, u.b would be folded to 0x45678 instead of
0x12345.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
@ 2014-08-12 2:16 ` thopre01 at gcc dot gnu.org
2014-08-12 2:21 ` thopre01 at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-08-12 2:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
thopre01 at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-08-12
Assignee|unassigned at gcc dot gnu.org |thopre01 at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from thopre01 at gcc dot gnu.org ---
Created attachment 33298
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33298&action=edit
Testcase: bitfield in a union
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
2014-08-12 2:16 ` [Bug middle-end/62103] " thopre01 at gcc dot gnu.org
@ 2014-08-12 2:21 ` thopre01 at gcc dot gnu.org
2014-08-12 2:37 ` thopre01 at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-08-12 2:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #2 from thopre01 at gcc dot gnu.org ---
I forgot to mention the flag to use: -O1 and whatever flag is necessary to
select a big endian target (for instance -mbig-endian if the target is arm
little endian by default).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
2014-08-12 2:16 ` [Bug middle-end/62103] " thopre01 at gcc dot gnu.org
2014-08-12 2:21 ` thopre01 at gcc dot gnu.org
@ 2014-08-12 2:37 ` thopre01 at gcc dot gnu.org
2014-08-14 6:17 ` thopre01 at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-08-12 2:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #3 from thopre01 at gcc dot gnu.org ---
Author: thopre01
Date: Tue Aug 12 02:36:37 2014
New Revision: 213846
URL: https://gcc.gnu.org/viewcvs?rev=213846&root=gcc&view=rev
Log:
2014-08-12 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
PR middle-end/62103
* gimple-fold.c (fold_ctor_reference): Don't fold in presence of
bitfields, that is when size doesn't match the size of type or the
size of the constructor.
gcc/testsuite/
PR middle-end/62103
* gcc.c-torture/execute/bitfld-6.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/bitfld-6.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-fold.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (2 preceding siblings ...)
2014-08-12 2:37 ` thopre01 at gcc dot gnu.org
@ 2014-08-14 6:17 ` thopre01 at gcc dot gnu.org
2014-12-17 11:52 ` thopre01 at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-08-14 6:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #5 from thopre01 at gcc dot gnu.org ---
Author: thopre01
Date: Thu Aug 14 06:16:56 2014
New Revision: 213941
URL: https://gcc.gnu.org/viewcvs?rev=213941&root=gcc&view=rev
Log:
2014-08-14 Thomas Preud'homme <thomas.preudhomme@arm.com>
Backport from mainline
2014-08-12 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
PR middle-end/62103
* gimple-fold.c (fold_ctor_reference): Don't fold in presence of
bitfields, that is when size doesn't match the size of type or the
size of the constructor.
gcc/testsuite/
PR middle-end/62103
* gcc.c-torture/execute/bitfld-6.c: New test.
Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/bitfld-6.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/gimple-fold.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (3 preceding siblings ...)
2014-08-14 6:17 ` thopre01 at gcc dot gnu.org
@ 2014-12-17 11:52 ` thopre01 at gcc dot gnu.org
2015-01-27 22:31 ` jiwang at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2014-12-17 11:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
thopre01 at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from thopre01 at gcc dot gnu.org ---
Fixed in all the branch currently supported
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (4 preceding siblings ...)
2014-12-17 11:52 ` thopre01 at gcc dot gnu.org
@ 2015-01-27 22:31 ` jiwang at gcc dot gnu.org
2015-01-27 22:32 ` jiwang at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiwang at gcc dot gnu.org @ 2015-01-27 22:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
Jiong Wang <jiwang at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jiwang at gcc dot gnu.org
--- Comment #7 from Jiong Wang <jiwang at gcc dot gnu.org> ---
*** Bug 64822 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (5 preceding siblings ...)
2015-01-27 22:31 ` jiwang at gcc dot gnu.org
@ 2015-01-27 22:32 ` jiwang at gcc dot gnu.org
2015-01-27 22:34 ` jiwang at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiwang at gcc dot gnu.org @ 2015-01-27 22:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #8 from Jiong Wang <jiwang at gcc dot gnu.org> ---
looks like this fix is too conservative. it will disable const fold for
bit-field completely. for bitfld-6/little-endian, previously, we can generated
main:
mov w0, 0
ret
while after this patch, we always load from memory. any specific reason for
this?
shouldn't we fix the code to let big-endian get correct folded constant?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (6 preceding siblings ...)
2015-01-27 22:32 ` jiwang at gcc dot gnu.org
@ 2015-01-27 22:34 ` jiwang at gcc dot gnu.org
2015-01-28 2:58 ` thopre01 at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiwang at gcc dot gnu.org @ 2015-01-27 22:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
Jiong Wang <jiwang at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #9 from Jiong Wang <jiwang at gcc dot gnu.org> ---
(In reply to Jiong Wang from comment #8)
>
> while after this patch, we always load from memory. any specific reason for
> this?
>
> shouldn't we fix the code to let big-endian get correct folded constant?
and similar bug still exist as 64822
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (7 preceding siblings ...)
2015-01-27 22:34 ` jiwang at gcc dot gnu.org
@ 2015-01-28 2:58 ` thopre01 at gcc dot gnu.org
2015-01-28 9:30 ` thopre01 at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2015-01-28 2:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #10 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
(In reply to Jiong Wang from comment #8)
> looks like this fix is too conservative. it will disable const fold for
> bit-field completely. for bitfld-6/little-endian, previously, we can
> generated
>
> main:
> mov w0, 0
> ret
>
> while after this patch, we always load from memory. any specific reason for
> this?
>
> shouldn't we fix the code to let big-endian get correct folded constant?
We only disable const folding for initialization of bitfields in a union. The
rationale was that the fix was much simpler (and could thus be backported) and
accessing a bitfield in a union that was initialized with a constant rare
enough that it wasn't worth the extra effort anyway. If this latter assumption
proves to be wrong I have the beginning of a patch that make
double_int::from_buffer and wi::from_buffer work at the bit level. It would
need to be extended to do the same to ::to_buffer.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (8 preceding siblings ...)
2015-01-28 2:58 ` thopre01 at gcc dot gnu.org
@ 2015-01-28 9:30 ` thopre01 at gcc dot gnu.org
2015-02-04 8:23 ` thopre01 at gcc dot gnu.org
2015-05-18 2:03 ` thopre01 at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2015-01-28 9:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #11 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
Ok, I have a local fix. The existing testcase didn't catch it because the
precision of the bitfield is not a multiple of CHAR_BITS.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (9 preceding siblings ...)
2015-01-28 9:30 ` thopre01 at gcc dot gnu.org
@ 2015-02-04 8:23 ` thopre01 at gcc dot gnu.org
2015-05-18 2:03 ` thopre01 at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2015-02-04 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #12 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
Author: thopre01
Date: Wed Feb 4 08:22:45 2015
New Revision: 220390
URL: https://gcc.gnu.org/viewcvs?rev=220390&root=gcc&view=rev
Log:
2015-02-04 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
PR middle-end/62103
* tree-ssa-sccvn.c (fully_constant_vn_reference_p): Use TYPE_PRECISION
to compute size of referenced value in the constant case.
gcc/testsuite/
PR middle-end/62103
* gcc.c-torture/execute/bitfld-7.c: New test adapted from bitfld-6.c
to use 24 bits for bitfield b.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/bitfld-7.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-sccvn.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
` (10 preceding siblings ...)
2015-02-04 8:23 ` thopre01 at gcc dot gnu.org
@ 2015-05-18 2:03 ` thopre01 at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: thopre01 at gcc dot gnu.org @ 2015-05-18 2:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
Thomas Preud'homme <thopre01 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #13 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
Fixed in all maintained branches.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-05-18 2:03 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-12 2:14 [Bug middle-end/62103] New: Incorrect folding of bitfield in a union on big endian targets thopre01 at gcc dot gnu.org
2014-08-12 2:16 ` [Bug middle-end/62103] " thopre01 at gcc dot gnu.org
2014-08-12 2:21 ` thopre01 at gcc dot gnu.org
2014-08-12 2:37 ` thopre01 at gcc dot gnu.org
2014-08-14 6:17 ` thopre01 at gcc dot gnu.org
2014-12-17 11:52 ` thopre01 at gcc dot gnu.org
2015-01-27 22:31 ` jiwang at gcc dot gnu.org
2015-01-27 22:32 ` jiwang at gcc dot gnu.org
2015-01-27 22:34 ` jiwang at gcc dot gnu.org
2015-01-28 2:58 ` thopre01 at gcc dot gnu.org
2015-01-28 9:30 ` thopre01 at gcc dot gnu.org
2015-02-04 8:23 ` thopre01 at gcc dot gnu.org
2015-05-18 2:03 ` thopre01 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).