* [Bug tree-optimization/104276] Fail to eliminate deadstore from vector constructor
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
@ 2022-01-28 23:33 ` pinskia at gcc dot gnu.org
2022-01-28 23:33 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] Fail to eliminate deadstore from vector constructor
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
2022-01-28 23:33 ` [Bug tree-optimization/104276] " pinskia at gcc dot gnu.org
@ 2022-01-28 23:33 ` pinskia at gcc dot gnu.org
2022-01-28 23:35 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Full testcase:
#include <cstdint>
#include <iterator>
#include <type_traits>
#include <vector>
#include <cstring>
#define SZ 4096
std::vector<int> foo() {
auto result = std::vector<int>(SZ);
int *ptr = result.data();
for (std::size_t n = 0; n < SZ; ++n) {
ptr[n] = static_cast<int>( n );
}
return result;
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] Fail to eliminate deadstore from vector constructor
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
2022-01-28 23:33 ` [Bug tree-optimization/104276] " pinskia at gcc dot gnu.org
2022-01-28 23:33 ` pinskia at gcc dot gnu.org
@ 2022-01-28 23:35 ` pinskia at gcc dot gnu.org
2022-01-28 23:37 ` Darrell.Wright at gmail dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 23:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>clang is unable to remove the memset in code like
I think you mean GCC there :).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] Fail to eliminate deadstore from vector constructor
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
` (2 preceding siblings ...)
2022-01-28 23:35 ` pinskia at gcc dot gnu.org
@ 2022-01-28 23:37 ` Darrell.Wright at gmail dot com
2022-01-28 23:40 ` [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Darrell.Wright at gmail dot com @ 2022-01-28 23:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
--- Comment #3 from Darrell Wright <Darrell.Wright at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> >clang is unable to remove the memset in code like
>
> I think you mean GCC there :).
:) both are true. This optimization would remove the need for things like
resize_and_overwrite which means we all win
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
` (3 preceding siblings ...)
2022-01-28 23:37 ` Darrell.Wright at gmail dot com
@ 2022-01-28 23:40 ` pinskia at gcc dot gnu.org
2022-01-28 23:44 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 23:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Fail to eliminate deadstore |memset is not elimited when
|from vector constructor |followed by a store loop
| |writing to that memory
| |location
Last reconfirmed| |2022-01-28
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Simplified C testcase (without std::vector usage):
#define SZ 4096
void foo1(int *a) {
__builtin_memset(a, 0, sizeof(int)*SZ);
for (int n = 0; n < SZ; ++n) {
a[n] = n;
}
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
` (4 preceding siblings ...)
2022-01-28 23:40 ` [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location pinskia at gcc dot gnu.org
@ 2022-01-28 23:44 ` pinskia at gcc dot gnu.org
2022-01-28 23:45 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 23:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Exact duplicate of PR 28134.
*** This bug has been marked as a duplicate of bug 28134 ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
` (5 preceding siblings ...)
2022-01-28 23:44 ` pinskia at gcc dot gnu.org
@ 2022-01-28 23:45 ` pinskia at gcc dot gnu.org
2022-01-31 8:15 ` rguenth at gcc dot gnu.org
2022-07-15 19:14 ` Darrell.Wright at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 23:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |NEW
Resolution|DUPLICATE |---
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually not an exact sorry still only related.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
` (6 preceding siblings ...)
2022-01-28 23:45 ` pinskia at gcc dot gnu.org
@ 2022-01-31 8:15 ` rguenth at gcc dot gnu.org
2022-07-15 19:14 ` Darrell.Wright at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-31 8:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
DSE could in theory prune live-bytes from a store inside a loop by looking at
SCEV / niter info. That'll cost though, and it's not clear where it would
nicely fit.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/104276] memset is not elimited when followed by a store loop writing to that memory location
2022-01-28 23:16 [Bug c++/104276] New: Fail to eliminate deadstore from vector constructor Darrell.Wright at gmail dot com
` (7 preceding siblings ...)
2022-01-31 8:15 ` rguenth at gcc dot gnu.org
@ 2022-07-15 19:14 ` Darrell.Wright at gmail dot com
8 siblings, 0 replies; 10+ messages in thread
From: Darrell.Wright at gmail dot com @ 2022-07-15 19:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104276
--- Comment #8 from Darrell Wright <Darrell.Wright at gmail dot com> ---
What about something like a __builtin_overwrite( ptr, size_t ) that tells the
compiler that the range specified will be written. It forms a contract to do
so with the compiler and would allow the memset to be eliminated or augmented
to part of the range
^ permalink raw reply [flat|nested] 10+ messages in thread