public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one
@ 2021-02-03 14:55 gabravier at gmail dot com
2021-02-04 7:42 ` [Bug tree-optimization/98953] " rguenth at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: gabravier at gmail dot com @ 2021-02-03 14:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
Bug ID: 98953
Summary: Failure to optimize two reads from adjacent addresses
into one
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int f(uint8_t *read, size_t abs)
{
return read[abs] + 0x100 * read[abs + 1];;
}
This can be optimized to (ignoring aliasing) `return *(uint16_t *)(read +
abs)`. This transformation is done by LLVM, but not by GCC.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
@ 2021-02-04 7:42 ` rguenth at gcc dot gnu.org
2021-07-28 21:27 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-04 7:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-02-04
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. The bswap would be the place that detects similar cases but I think
it doesn't consider this case because the number is "incomplete" and because
the pass doesnt' consider PLUS_EXPR or MULT_EXPR AFAIR. Also it doesn't
handle non-obviously same bases gracefully.
The following works:
#include <stdint.h>
#include <stdlib.h>
int f(uint8_t *read, size_t abs)
{
return read[0] + (read[1] << 8);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
2021-02-04 7:42 ` [Bug tree-optimization/98953] " rguenth at gcc dot gnu.org
@ 2021-07-28 21:27 ` pinskia at gcc dot gnu.org
2021-11-22 8:44 ` roger at nextmovesoftware dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-28 21:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Last reconfirmed|2021-02-04 00:00:00 |2021-7-28
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
2021-02-04 7:42 ` [Bug tree-optimization/98953] " rguenth at gcc dot gnu.org
2021-07-28 21:27 ` pinskia at gcc dot gnu.org
@ 2021-11-22 8:44 ` roger at nextmovesoftware dot com
2021-11-22 18:17 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: roger at nextmovesoftware dot com @ 2021-11-22 8:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |roger at nextmovesoftware dot com
Status|NEW |ASSIGNED
CC| |roger at nextmovesoftware dot com
--- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> ---
Patch proposed
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585117.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
` (2 preceding siblings ...)
2021-11-22 8:44 ` roger at nextmovesoftware dot com
@ 2021-11-22 18:17 ` cvs-commit at gcc dot gnu.org
2021-11-25 20:05 ` roger at nextmovesoftware dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-22 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:
https://gcc.gnu.org/g:a944b5dec3adb28ed199234d2116145ca9010d6a
commit r12-5453-ga944b5dec3adb28ed199234d2116145ca9010d6a
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Mon Nov 22 18:15:36 2021 +0000
tree-optimization/103345: Improved load merging.
This patch implements PR tree-optimization/103345 to merge adjacent
loads when combined with addition or bitwise xor. The current code
in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior,
so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in
the same way at BIT_IOR_EXPR. Many thanks to Andrew Pinski for
pointing out that this also resolves PR target/98953.
2021-11-22 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/98953
PR tree-optimization/103345
* gimple-ssa-store-merging.c (find_bswap_or_nop_1): Handle
BIT_XOR_EXPR and PLUS_EXPR the same as BIT_IOR_EXPR.
(pass_optimize_bswap::execute): Likewise.
gcc/testsuite/ChangeLog
PR tree-optimization/98953
PR tree-optimization/103345
* gcc.dg/tree-ssa/pr98953.c: New test case.
* gcc.dg/tree-ssa/pr103345.c: New test case.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
` (3 preceding siblings ...)
2021-11-22 18:17 ` cvs-commit at gcc dot gnu.org
@ 2021-11-25 20:05 ` roger at nextmovesoftware dot com
2021-12-15 23:31 ` pinskia at gcc dot gnu.org
2024-01-14 21:44 ` [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one due to having an offset (index) pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: roger at nextmovesoftware dot com @ 2021-11-25 20:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
Assignee|roger at nextmovesoftware dot com |unassigned at gcc dot gnu.org
--- Comment #4 from Roger Sayle <roger at nextmovesoftware dot com> ---
The MULT_EXPR and PLUS_EXPR aspects of this PR are now resolved (i.e. the case
in comment #1), but unfortunately the abs-based indexing used in the original
report still causes problems. The bswap pass doesn't yet handle memory
accesses of the form read[abs]/read[abs+1] (but does handle read[0]/read[1]).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
` (4 preceding siblings ...)
2021-11-25 20:05 ` roger at nextmovesoftware dot com
@ 2021-12-15 23:31 ` pinskia at gcc dot gnu.org
2024-01-14 21:44 ` [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one due to having an offset (index) pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-15 23:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 102391 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one due to having an offset (index)
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
` (5 preceding siblings ...)
2021-12-15 23:31 ` pinskia at gcc dot gnu.org
@ 2024-01-14 21:44 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-14 21:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98953
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |llvm at rifkin dot dev
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 113392 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-01-14 21:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 14:55 [Bug tree-optimization/98953] New: Failure to optimize two reads from adjacent addresses into one gabravier at gmail dot com
2021-02-04 7:42 ` [Bug tree-optimization/98953] " rguenth at gcc dot gnu.org
2021-07-28 21:27 ` pinskia at gcc dot gnu.org
2021-11-22 8:44 ` roger at nextmovesoftware dot com
2021-11-22 18:17 ` cvs-commit at gcc dot gnu.org
2021-11-25 20:05 ` roger at nextmovesoftware dot com
2021-12-15 23:31 ` pinskia at gcc dot gnu.org
2024-01-14 21:44 ` [Bug tree-optimization/98953] Failure to optimize two reads from adjacent addresses into one due to having an offset (index) 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).