public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/110514] New: d: accesses immutable arrays using constant index still bounds checked
@ 2023-07-01 19:33 ibuclaw at gcc dot gnu.org
2023-07-01 23:18 ` [Bug d/110514] d: accesses of " cvs-commit at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-07-01 19:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110514
Bug ID: 110514
Summary: d: accesses immutable arrays using constant index
still bounds checked
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gcc dot gnu.org
Target Milestone: ---
For example:
---
immutable uint[] arr = [1,2,3];
void test()
{
immutable uint* p = arr.ptr;
if (arr[0]== p[0] && arr[1] == p[1] && arr[2] == p[2])
return;
assert(0);
}
---
Although the size and value of `arr` is known at compile-time, and is
guaranteed to never change at run-time, there are still three calls to
`_d_arrayboundsp` inserted into the program.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/110514] d: accesses of immutable arrays using constant index still bounds checked
2023-07-01 19:33 [Bug d/110514] New: d: accesses immutable arrays using constant index still bounds checked ibuclaw at gcc dot gnu.org
@ 2023-07-01 23:18 ` cvs-commit at gcc dot gnu.org
2023-07-01 23:19 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-01 23:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110514
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:61b1c562f8c703bff045e91257120e42b7fae523
commit r14-2234-g61b1c562f8c703bff045e91257120e42b7fae523
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sat Jul 1 23:32:53 2023 +0200
d: Fix accesses of immutable arrays using constant index still bounds
checked
Starts setting TREE_READONLY against specific kinds of VAR_DECLs, so
that the middle-end/optimization passes can more aggressively constant
fold D code that makes use of `immutable' or `const'.
PR d/110514
gcc/d/ChangeLog:
* decl.cc (get_symbol_decl): Set TREE_READONLY on certain kinds of
const and immutable variables.
* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Set
TREE_READONLY
on immutable dynamic array literals.
gcc/testsuite/ChangeLog:
* gdc.dg/pr110514a.d: New test.
* gdc.dg/pr110514b.d: New test.
* gdc.dg/pr110514c.d: New test.
* gdc.dg/pr110514d.d: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/110514] d: accesses of immutable arrays using constant index still bounds checked
2023-07-01 19:33 [Bug d/110514] New: d: accesses immutable arrays using constant index still bounds checked ibuclaw at gcc dot gnu.org
2023-07-01 23:18 ` [Bug d/110514] d: accesses of " cvs-commit at gcc dot gnu.org
@ 2023-07-01 23:19 ` cvs-commit at gcc dot gnu.org
2023-07-01 23:20 ` cvs-commit at gcc dot gnu.org
2023-07-01 23:22 ` ibuclaw at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-01 23:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110514
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:3f43c19d0d40b82ecfd10f277322c1f786bcd76d
commit r13-7519-g3f43c19d0d40b82ecfd10f277322c1f786bcd76d
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sat Jul 1 23:32:53 2023 +0200
d: Fix accesses of immutable arrays using constant index still bounds
checked
Starts setting TREE_READONLY against specific kinds of VAR_DECLs, so
that the middle-end/optimization passes can more aggressively constant
fold D code that makes use of `immutable' or `const'.
PR d/110514
gcc/d/ChangeLog:
* decl.cc (get_symbol_decl): Set TREE_READONLY on certain kinds of
const and immutable variables.
* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Set
TREE_READONLY
on immutable dynamic array literals.
gcc/testsuite/ChangeLog:
* gdc.dg/pr110514a.d: New test.
* gdc.dg/pr110514b.d: New test.
* gdc.dg/pr110514c.d: New test.
* gdc.dg/pr110514d.d: New test.
(cherry picked from commit 61b1c562f8c703bff045e91257120e42b7fae523)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/110514] d: accesses of immutable arrays using constant index still bounds checked
2023-07-01 19:33 [Bug d/110514] New: d: accesses immutable arrays using constant index still bounds checked ibuclaw at gcc dot gnu.org
2023-07-01 23:18 ` [Bug d/110514] d: accesses of " cvs-commit at gcc dot gnu.org
2023-07-01 23:19 ` cvs-commit at gcc dot gnu.org
@ 2023-07-01 23:20 ` cvs-commit at gcc dot gnu.org
2023-07-01 23:22 ` ibuclaw at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-01 23:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110514
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:750526ee180ae2af66ee07db95c9787e8d86ed4b
commit r12-9747-g750526ee180ae2af66ee07db95c9787e8d86ed4b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sat Jul 1 23:32:53 2023 +0200
d: Fix accesses of immutable arrays using constant index still bounds
checked
Starts setting TREE_READONLY against specific kinds of VAR_DECLs, so
that the middle-end/optimization passes can more aggressively constant
fold D code that makes use of `immutable' or `const'.
PR d/110514
gcc/d/ChangeLog:
* decl.cc (get_symbol_decl): Set TREE_READONLY on certain kinds of
const and immutable variables.
* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Set
TREE_READONLY
on immutable dynamic array literals.
gcc/testsuite/ChangeLog:
* gdc.dg/pr110514a.d: New test.
* gdc.dg/pr110514b.d: New test.
* gdc.dg/pr110514c.d: New test.
* gdc.dg/pr110514d.d: New test.
(cherry picked from commit 61b1c562f8c703bff045e91257120e42b7fae523)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug d/110514] d: accesses of immutable arrays using constant index still bounds checked
2023-07-01 19:33 [Bug d/110514] New: d: accesses immutable arrays using constant index still bounds checked ibuclaw at gcc dot gnu.org
` (2 preceding siblings ...)
2023-07-01 23:20 ` cvs-commit at gcc dot gnu.org
@ 2023-07-01 23:22 ` ibuclaw at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ibuclaw at gcc dot gnu.org @ 2023-07-01 23:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110514
ibuclaw at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from ibuclaw at gcc dot gnu.org ---
Fix committed and backported.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-01 23:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-01 19:33 [Bug d/110514] New: d: accesses immutable arrays using constant index still bounds checked ibuclaw at gcc dot gnu.org
2023-07-01 23:18 ` [Bug d/110514] d: accesses of " cvs-commit at gcc dot gnu.org
2023-07-01 23:19 ` cvs-commit at gcc dot gnu.org
2023-07-01 23:20 ` cvs-commit at gcc dot gnu.org
2023-07-01 23:22 ` ibuclaw 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).