public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR @ 2024-01-15 10:49 rguenth at gcc dot gnu.org 2024-01-15 11:54 ` [Bug middle-end/113395] " rguenth at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-01-15 10:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113395 Bug ID: 113395 Summary: RTL expansion drops MEM_EXPR Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- struct S { signed m : 7; signed e : 2; } g; void k() { g.e ^= 1; } expands as (insn 8 7 0 (parallel [ (set (mem/j/c:HI (reg/f:DI 100) [0 +0 S2 A32]) (xor:HI (mem/j/c:HI (reg/f:DI 100) [0 +0 S2 A32]) (reg:HI 101))) (clobber (reg:CC 17 flags)) ]) "t.c":9:7 -1 (nil)) similar g.e = 1; (insn 9 8 10 (set (reg:HI 102) (mem/j/c:HI (reg/f:DI 101) [0 +0 S2 A32])) "t.c":9:7 -1 (nil)) ... (insn 12 11 0 (set (mem/j/c:HI (reg/f:DI 101) [0 +0 S2 A32]) (reg:HI 104)) "t.c":9:7 -1 (nil)) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/113395] RTL expansion drops MEM_EXPR 2024-01-15 10:49 [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR rguenth at gcc dot gnu.org @ 2024-01-15 11:54 ` rguenth at gcc dot gnu.org 2024-01-15 11:57 ` [Bug middle-end/113395] RTL expansion of bitfield accesses " rguenth at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-01-15 11:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113395 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Because of #0 adjust_address_1 (memref=0x7ffff71e8db0, mode=E_HImode, offset=..., validate=1, adjust_address=1, adjust_object=1, size=...) at /space/rguenther/src/gcc/gcc/emit-rtl.cc:2409 #1 0x00000000011459af in narrow_bit_field_mem (mem=0x7ffff71e8db0, mode=HImode, bitsize=2, bitnum=7, new_bitnum=0x7fffffffc8c0) at /space/rguenther/src/gcc/gcc/expmed.cc:453 #2 0x0000000001145d1c in adjust_bit_field_mem_for_reg (pattern=EP_insv, op0=0x7ffff71e8db0, bitsize=2, bitnum=7, bitregion_start=..., bitregion_end=..., fieldmode=E_VOIDmode, new_bitnum=0x7fffffffc8c0) at /space/rguenther/src/gcc/gcc/expmed.cc:511 #3 0x00000000011483bb in store_integral_bit_field (op0=0x7ffff71e8db0, op0_mode=SImode, bitsize=2, bitnum=7, bitregion_start=..., bitregion_end=..., fieldmode=E_VOIDmode, value=0x7ffff70124a0, reverse=false, fallback_p=true) at /space/rguenther/src/gcc/gcc/expmed.cc:1086 #4 0x00000000011476a0 in store_bit_field_1 (str_rtx=0x7ffff71e8db0, bitsize=..., bitnum=..., bitregion_start=..., bitregion_end=..., fieldmode=E_VOIDmode, value=0x7ffff70124a0, reverse=false, fallback_p=true, undefined_p=false) at /space/rguenther/src/gcc/gcc/expmed.cc:887 #5 0x0000000001148c31 in store_bit_field (str_rtx=0x7ffff71e8db0, bitsize=..., bitnum=..., bitregion_start=..., bitregion_end=..., fieldmode=E_VOIDmode, value=0x7ffff70124a0, reverse=false, --Type <RET> for more, q to quit, c to continue without paging-- ) at /space/rguenther/src/gcc/gcc/expmed.cc:1194 #6 0x000000000117dde0 in store_field (target=0x7ffff71e8db0, bitsize=..., bitpos=..., bitregion_start=..., bitregion_end=..., mode=E_VOIDmode, exp=<integer_cst 0x7ffff71c4ca8>, alias_set=1, nontemporal=false, reverse=false) at /space/rguenther/src/gcc/gcc/expr.cc:8245 #7 0x0000000001174b21 in expand_assignment ( to=<component_ref 0x7ffff71e07b0>, from=<integer_cst 0x7ffff71c4ca8>, nontemporal=false) at /space/rguenther/src/gcc/gcc/expr.cc:6303 and we run into if (maybe_ne (size, 0)) { /* Drop the object if the new right end is not within its bounds. */ if (adjust_object && maybe_gt (offset + size, attrs.size)) { attrs.expr = NULL_TREE; attrs.alias = 0; } as attrs.size is originally 1 and we are creating a two byte HImode access. IMHO it's the fault of how we set up the initial memory attributes which come via expand_assignment doing tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1, &unsignedp, &reversep, &volatilep); .. if (TREE_CODE (to) == COMPONENT_REF && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1))) get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset); .. to_rtx = expand_expr (tem, NULL_RTX, VOIDmode, EXPAND_WRITE); .. if (MEM_P (to_rtx)) { /* If the field is at offset zero, we could have been given the DECL_RTX of the parent struct. Don't munge it. */ to_rtx = shallow_copy_rtx (to_rtx); set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos); if (volatilep) MEM_VOLATILE_P (to_rtx) = 1; that's an unfortunate setup to eventually widen the setup. RTL alias analysis then has to rely on find_base_term to perform it's bogus optimistic points-to analysis. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/113395] RTL expansion of bitfield accesses drops MEM_EXPR 2024-01-15 10:49 [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR rguenth at gcc dot gnu.org 2024-01-15 11:54 ` [Bug middle-end/113395] " rguenth at gcc dot gnu.org @ 2024-01-15 11:57 ` rguenth at gcc dot gnu.org 2024-01-15 22:55 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-01-15 11:57 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113395 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|RTL expansion drops |RTL expansion of bitfield |MEM_EXPR |accesses drops MEM_EXPR Blocks| |113255 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- gcc.dg/tree-ssa/pr94969.c for example misses RTL PRE when we dumb down find_base_term to be conservatively correct. GIMPLE invariant motion doesn't handle the involved aggregate copy which on RTL maps to SImode. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113255 [Bug 113255] [11/12/13/14 Regression] wrong code with -O2 -mtune=k8 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/113395] RTL expansion of bitfield accesses drops MEM_EXPR 2024-01-15 10:49 [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR rguenth at gcc dot gnu.org 2024-01-15 11:54 ` [Bug middle-end/113395] " rguenth at gcc dot gnu.org 2024-01-15 11:57 ` [Bug middle-end/113395] RTL expansion of bitfield accesses " rguenth at gcc dot gnu.org @ 2024-01-15 22:55 ` pinskia at gcc dot gnu.org 2024-01-15 22:58 ` pinskia at gcc dot gnu.org 2024-01-16 9:27 ` rguenth at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-01-15 22:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113395 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2024-01-15 Status|UNCONFIRMED |NEW --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am almost positive there is a dup of this bug somewhere ... ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/113395] RTL expansion of bitfield accesses drops MEM_EXPR 2024-01-15 10:49 [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR rguenth at gcc dot gnu.org ` (2 preceding siblings ...) 2024-01-15 22:55 ` pinskia at gcc dot gnu.org @ 2024-01-15 22:58 ` pinskia at gcc dot gnu.org 2024-01-16 9:27 ` rguenth at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-01-15 22:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113395 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |45274 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > I am almost positive there is a dup of this bug somewhere ... Yes PR 45274 where the aliasing set is 0 ... Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45274 [Bug 45274] __restrict__ type qualifier does not work on pointers to bitfields ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/113395] RTL expansion of bitfield accesses drops MEM_EXPR 2024-01-15 10:49 [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR rguenth at gcc dot gnu.org ` (3 preceding siblings ...) 2024-01-15 22:58 ` pinskia at gcc dot gnu.org @ 2024-01-16 9:27 ` rguenth at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-01-16 9:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113395 --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Without fully lowering this on GIMPLE we could substitute the representative for the bitfield member in the MEM_EXPR and adjust adjust_address_1 to instead of using attrs.size to constrain the extent of the object designated by MEM_EXPR re-discover it. (I wonder if MEM_SIZE needs to be exact in a must-def way - ao_ref_from_mem certainly treats it that way instead of getting the size from the mode for non-BLKmode accesses) That said, lowering on GIMPLE is the way to go. Even iff only right before RTL expansion ... ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-16 9:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-01-15 10:49 [Bug middle-end/113395] New: RTL expansion drops MEM_EXPR rguenth at gcc dot gnu.org 2024-01-15 11:54 ` [Bug middle-end/113395] " rguenth at gcc dot gnu.org 2024-01-15 11:57 ` [Bug middle-end/113395] RTL expansion of bitfield accesses " rguenth at gcc dot gnu.org 2024-01-15 22:55 ` pinskia at gcc dot gnu.org 2024-01-15 22:58 ` pinskia at gcc dot gnu.org 2024-01-16 9:27 ` 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).