public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116514] New: known pointer alignment is not used for constant propagation
@ 2024-08-28 11:15 mkretz at gcc dot gnu.org
2024-08-28 11:38 ` [Bug c++/116514] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: mkretz at gcc dot gnu.org @ 2024-08-28 11:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116514
Bug ID: 116514
Summary: known pointer alignment is not used for constant
propagation
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mkretz at gcc dot gnu.org
Target Milestone: ---
Test case (https://compiler-explorer.com/z/Gxd9KaG1T):
int
test(int* a, int* b)
{
auto delta = (int*)__builtin_assume_aligned(b, 32)
- (int*)__builtin_assume_aligned(a, 32);
auto x = delta % 8;
return (x == 0);
}
The expression 'delta % 8' should be optimized to a 0 constant. Consequently 'x
== 0' must satisfy __builtin_constant_p and be true. This could then be used to
completely avoid emitting code for a SIMD epilogue for given a range.
Clang manages to fold the above function to a constant 1.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/116514] known pointer alignment is not used for constant propagation
2024-08-28 11:15 [Bug c++/116514] New: known pointer alignment is not used for constant propagation mkretz at gcc dot gnu.org
@ 2024-08-28 11:38 ` rguenth at gcc dot gnu.org
2024-09-09 13:02 ` cvs-commit at gcc dot gnu.org
2024-09-09 13:04 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-08-28 11:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116514
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Last reconfirmed| |2024-08-28
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
CCP fails to handle
Visiting statement:
delta_7 = _3 /[ex] 4;
which is likely CONSTANT
Lattice value changed to VARYING. Adding SSA edges to worklist.
so we get
Visiting statement:
x_8 = delta_7 % 8;
which is likely CONSTANT
Lattice value changed to VARYING. Adding SSA edges to worklist.
despite
Visiting statement:
_3 = _1 - _2;
which is likely CONSTANT
Lattice value changed to CONSTANT 0x0 (0xffff...<1000s?!>...fffe0).
bit_value_binop supports TRUNC_DIV_EXPR but not EXACT_DIV_EXPR.
That's trivial to add.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/116514] known pointer alignment is not used for constant propagation
2024-08-28 11:15 [Bug c++/116514] New: known pointer alignment is not used for constant propagation mkretz at gcc dot gnu.org
2024-08-28 11:38 ` [Bug c++/116514] " rguenth at gcc dot gnu.org
@ 2024-09-09 13:02 ` cvs-commit at gcc dot gnu.org
2024-09-09 13:04 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-09 13:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116514
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:e7d5b9aa021f6fc32810670b18ffabe543262775
commit r15-3548-ge7d5b9aa021f6fc32810670b18ffabe543262775
Author: Richard Biener <rguenther@suse.de>
Date: Wed Aug 28 14:06:48 2024 +0200
tree-optimization/116514 - handle pointer difference in bit-CCP
When evaluating the difference of two aligned pointers in CCP we
fail to handle the EXACT_DIV_EXPR by the element size that occurs.
The testcase then also exercises modulo to test alignment but
modulo by a power-of-two isn't handled either.
PR tree-optimization/116514
* tree-ssa-ccp.cc (bit_value_binop): Handle EXACT_DIV_EXPR
like TRUNC_DIV_EXPR. Handle exact division of a signed value
by a power-of-two like a shift. Handle unsigned division by
a power-of-two like a shift.
Handle unsigned TRUNC_MOD_EXPR by power-of-two, handle signed
TRUNC_MOD_EXPR by power-of-two if the result is zero.
* gcc.dg/tree-ssa/ssa-ccp-44.c: New testcase.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/116514] known pointer alignment is not used for constant propagation
2024-08-28 11:15 [Bug c++/116514] New: known pointer alignment is not used for constant propagation mkretz at gcc dot gnu.org
2024-08-28 11:38 ` [Bug c++/116514] " rguenth at gcc dot gnu.org
2024-09-09 13:02 ` cvs-commit at gcc dot gnu.org
@ 2024-09-09 13:04 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-09-09 13:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116514
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |15.0
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 15.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-09 13:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-28 11:15 [Bug c++/116514] New: known pointer alignment is not used for constant propagation mkretz at gcc dot gnu.org
2024-08-28 11:38 ` [Bug c++/116514] " rguenth at gcc dot gnu.org
2024-09-09 13:02 ` cvs-commit at gcc dot gnu.org
2024-09-09 13:04 ` 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).