public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/gjl/heads/gcc-8)] rtl-optimization/101188 - Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0
@ 2024-02-19 14:36 Georg-Johann Lay
0 siblings, 0 replies; 2+ messages in thread
From: Georg-Johann Lay @ 2024-02-19 14:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:900efd5c53f2738cfd136c70a32b26d182354f11
commit 900efd5c53f2738cfd136c70a32b26d182354f11
Author: Georg-Johann Lay <avr@gjlay.de>
Date: Mon Feb 19 13:31:08 2024 +0100
rtl-optimization/101188 - Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0
Use reduced version of the PR101188 fix that only handles CLOBBERs.
It's not clear how to backport the full fix from Jeff Law.
gcc/
PR rtl-optimization/101188
* postreload.c (reload_cse_move2add): Record effect of CLOBBERs.
* testsuite/gcc.c-torture/execute/pr101188.c: New test.
Diff:
---
gcc/ChangeLog | 9 ++++
gcc/postreload.c | 9 ++++
gcc/testsuite/gcc.c-torture/execute/pr101188.c | 60 ++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b9c7f42907b9..b87842429bec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-19 Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0
+
+ Use reduced version of the PR101188 fix that only handles CLOBBERs.
+ It's not clear how to backport the full fix from Jeff Law.
+
+ PR rtl-optimization/101188
+ * postreload.c (reload_cse_move2add): Record effect of CLOBBERs.
+ * testsuite/gcc.c-torture/execute/pr101188.c: New test.
+
2021-05-14 Release Manager
* GCC 8.5.0 released.
diff --git a/gcc/postreload.c b/gcc/postreload.c
index b97392337e70..51c395c11c12 100644
--- a/gcc/postreload.c
+++ b/gcc/postreload.c
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "cselib.h"
#include "tree-pass.h"
#include "dbgcnt.h"
+#include "rtl-iter.h"
static int reload_cse_noop_set_p (rtx);
static bool reload_cse_simplify (rtx_insn *, rtx);
@@ -2027,6 +2028,14 @@ reload_cse_move2add (rtx_insn *first)
if (success)
delete_insn (insn);
changed |= success;
+ // By setting "insn = next" below, we are bypassing the
+ // side-effects of next, see PR101188. Do them by hand
+ subrtx_iterator::array_type array;
+ FOR_EACH_SUBRTX (iter, array, PATTERN (next), NONCONST)
+ {
+ if (GET_CODE (*iter) == CLOBBER)
+ move2add_note_store (XEXP (*iter, 0), *iter, next);
+ }
insn = next;
move2add_record_mode (reg);
reg_offset[regno]
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr101188.c b/gcc/testsuite/gcc.c-torture/execute/pr101188.c
new file mode 100644
index 000000000000..460149ada492
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr101188.c
@@ -0,0 +1,60 @@
+typedef __UINT8_TYPE__ uint8_t;
+typedef __UINT16_TYPE__ uint16_t;
+
+typedef uint8_t (*fn1)(void *a);
+typedef void (*fn2)(void *a, int *arg);
+
+struct S
+{
+ uint8_t buffer[64];
+ uint16_t n;
+ fn2 f2;
+ void *a;
+ fn1 f1;
+};
+
+volatile uint16_t x;
+
+void __attribute__((__noinline__,__noclone__))
+foo (uint16_t n)
+{
+ x = n;
+}
+
+void __attribute__((__noinline__,__noclone__))
+testfn (struct S *self)
+{
+ int arg;
+
+ foo (self->n);
+ self->n++;
+ self->f2 (self->a, &arg);
+ self->buffer[0] = self->f1 (self->a);
+}
+
+static unsigned char myfn2_called = 0;
+
+static void
+myfn2 (void *a, int *arg)
+{
+ myfn2_called = 1;
+}
+
+static uint8_t
+myfn1 (void *a)
+{
+ return 0;
+}
+
+int main (void)
+{
+ struct S s;
+ s.n = 0;
+ s.f2 = myfn2;
+ s.f1 = myfn1;
+ testfn (&s);
+ if (myfn2_called != 1)
+ __builtin_abort();
+ return 0;
+}
+
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/users/gjl/heads/gcc-8)] rtl-optimization/101188 - Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0
@ 2024-02-19 14:49 Georg-Johann Lay
0 siblings, 0 replies; 2+ messages in thread
From: Georg-Johann Lay @ 2024-02-19 14:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:071bd78ee13ec34191869168d04b015833a5014f
commit 071bd78ee13ec34191869168d04b015833a5014f
Author: Georg-Johann Lay <avr@gjlay.de>
Date: Mon Feb 19 13:31:08 2024 +0100
rtl-optimization/101188 - Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0
Use reduced version of the PR101188 fix that only handles CLOBBERs.
It's not clear how to backport the full fix from Jeff Law.
gcc/
PR rtl-optimization/101188
* postreload.c (reload_cse_move2add): Record effect of CLOBBERs.
* testsuite/gcc.c-torture/execute/pr101188.c: New test.
Diff:
---
gcc/ChangeLog | 9 ++++
gcc/postreload.c | 9 ++++
gcc/testsuite/gcc.c-torture/execute/pr101188.c | 60 ++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b9c7f42907b9..b87842429bec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-19 Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0
+
+ Use reduced version of the PR101188 fix that only handles CLOBBERs.
+ It's not clear how to backport the full fix from Jeff Law.
+
+ PR rtl-optimization/101188
+ * postreload.c (reload_cse_move2add): Record effect of CLOBBERs.
+ * testsuite/gcc.c-torture/execute/pr101188.c: New test.
+
2021-05-14 Release Manager
* GCC 8.5.0 released.
diff --git a/gcc/postreload.c b/gcc/postreload.c
index b97392337e70..51c395c11c12 100644
--- a/gcc/postreload.c
+++ b/gcc/postreload.c
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "cselib.h"
#include "tree-pass.h"
#include "dbgcnt.h"
+#include "rtl-iter.h"
static int reload_cse_noop_set_p (rtx);
static bool reload_cse_simplify (rtx_insn *, rtx);
@@ -2027,6 +2028,14 @@ reload_cse_move2add (rtx_insn *first)
if (success)
delete_insn (insn);
changed |= success;
+ // By setting "insn = next" below, we are bypassing the
+ // side-effects of next, see PR101188. Do them by hand
+ subrtx_iterator::array_type array;
+ FOR_EACH_SUBRTX (iter, array, PATTERN (next), NONCONST)
+ {
+ if (GET_CODE (*iter) == CLOBBER)
+ move2add_note_store (XEXP (*iter, 0), *iter, next);
+ }
insn = next;
move2add_record_mode (reg);
reg_offset[regno]
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr101188.c b/gcc/testsuite/gcc.c-torture/execute/pr101188.c
new file mode 100644
index 000000000000..460149ada492
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr101188.c
@@ -0,0 +1,60 @@
+typedef __UINT8_TYPE__ uint8_t;
+typedef __UINT16_TYPE__ uint16_t;
+
+typedef uint8_t (*fn1)(void *a);
+typedef void (*fn2)(void *a, int *arg);
+
+struct S
+{
+ uint8_t buffer[64];
+ uint16_t n;
+ fn2 f2;
+ void *a;
+ fn1 f1;
+};
+
+volatile uint16_t x;
+
+void __attribute__((__noinline__,__noclone__))
+foo (uint16_t n)
+{
+ x = n;
+}
+
+void __attribute__((__noinline__,__noclone__))
+testfn (struct S *self)
+{
+ int arg;
+
+ foo (self->n);
+ self->n++;
+ self->f2 (self->a, &arg);
+ self->buffer[0] = self->f1 (self->a);
+}
+
+static unsigned char myfn2_called = 0;
+
+static void
+myfn2 (void *a, int *arg)
+{
+ myfn2_called = 1;
+}
+
+static uint8_t
+myfn1 (void *a)
+{
+ return 0;
+}
+
+int main (void)
+{
+ struct S s;
+ s.n = 0;
+ s.f2 = myfn2;
+ s.f1 = myfn1;
+ testfn (&s);
+ if (myfn2_called != 1)
+ __builtin_abort();
+ return 0;
+}
+
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-19 14:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 14:36 [gcc(refs/users/gjl/heads/gcc-8)] rtl-optimization/101188 - Backport from ae193f9008e02683e27f3c87f3b06f38e103b1d0 Georg-Johann Lay
2024-02-19 14:49 Georg-Johann Lay
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).