public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order @ 2022-10-24 7:48 krebbel at gcc dot gnu.org 2022-10-24 7:49 ` [Bug tree-optimization/107372] " krebbel at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: krebbel at gcc dot gnu.org @ 2022-10-24 7:48 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107372 Bug ID: 107372 Summary: Loop distribution create memcpy between structs with different storage order Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: krebbel at gcc dot gnu.org Target Milestone: --- For t.c with "gcc -O3 t.c": struct L { unsigned int val[256]; } __attribute__((scalar_storage_order ("little-endian"))); struct B { unsigned int val[256]; } __attribute__((scalar_storage_order ("big-endian"))); void foo (struct L *restrict l, struct B *restrict b) { int i; for (i = 0; i < 256; i++) l->val[i] = b->val[i]; } The loop distribution pass currently generates a memcpy although it recognizes correctly that both sides of the assignment have different storage order: Analyzing # of iterations of loop 1 exit condition [255, + , 4294967295] != 0 bounds on difference of bases: -255 ... -255 result: # of iterations 255, bounded by 255 Creating dr for *b_5(D).val[i_11] analyze_innermost: t.c:16:23: missed: failed: reverse storage order. ... void foo (struct L * restrict l, struct B * restrict b) { int i; <bb 2> [local count: 10737416]: __builtin_memcpy (l_6(D), b_5(D), 1024); return; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/107372] Loop distribution create memcpy between structs with different storage order 2022-10-24 7:48 [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order krebbel at gcc dot gnu.org @ 2022-10-24 7:49 ` krebbel at gcc dot gnu.org 2022-10-24 13:23 ` [Bug tree-optimization/107372] Loop distribution creates " rguenth at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: krebbel at gcc dot gnu.org @ 2022-10-24 7:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107372 --- Comment #1 from Andreas Krebbel <krebbel at gcc dot gnu.org> --- Created attachment 53764 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53764&action=edit Experimental Fix Looks like the error while analyzing the data ref is not propagated to the upper layers to actually prevent the optimization. This patch fixes this for me. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/107372] Loop distribution creates memcpy between structs with different storage order 2022-10-24 7:48 [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order krebbel at gcc dot gnu.org 2022-10-24 7:49 ` [Bug tree-optimization/107372] " krebbel at gcc dot gnu.org @ 2022-10-24 13:23 ` rguenth at gcc dot gnu.org 2024-03-10 0:44 ` pinskia at gcc dot gnu.org 2024-03-10 0:45 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-10-24 13:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107372 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Andreas Krebbel from comment #1) > Created attachment 53764 [details] > Experimental Fix > > Looks like the error while analyzing the data ref is not propagated to the > upper layers to actually prevent the optimization. This patch fixes this for > me. But that's on purpose I think. create_data_ref does never "fail", the caller has to check for proper analysis of the DR though. For loop distribution we should FAIL looking at DR_STEP? Ah, for example compute_access_range performs its own analysis so it needs to check for the storage order itself I think or the callers need to match up storage order of source and destination. Your patch leaks memory. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/107372] Loop distribution creates memcpy between structs with different storage order 2022-10-24 7:48 [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order krebbel at gcc dot gnu.org 2022-10-24 7:49 ` [Bug tree-optimization/107372] " krebbel at gcc dot gnu.org 2022-10-24 13:23 ` [Bug tree-optimization/107372] Loop distribution creates " rguenth at gcc dot gnu.org @ 2024-03-10 0:44 ` pinskia at gcc dot gnu.org 2024-03-10 0:45 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-03-10 0:44 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107372 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Fixed correctly by r13-4244-g55cb8c5c9abfe8 . ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/107372] Loop distribution creates memcpy between structs with different storage order 2022-10-24 7:48 [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order krebbel at gcc dot gnu.org ` (2 preceding siblings ...) 2024-03-10 0:44 ` pinskia at gcc dot gnu.org @ 2024-03-10 0:45 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-03-10 0:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107372 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |11.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-10 0:45 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-10-24 7:48 [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order krebbel at gcc dot gnu.org 2022-10-24 7:49 ` [Bug tree-optimization/107372] " krebbel at gcc dot gnu.org 2022-10-24 13:23 ` [Bug tree-optimization/107372] Loop distribution creates " rguenth at gcc dot gnu.org 2024-03-10 0:44 ` pinskia at gcc dot gnu.org 2024-03-10 0:45 ` pinskia 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).