public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] c: Add missing fold in build_binary_op
@ 2021-10-01 9:16 Matthew Malcomson
0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2021-10-01 9:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:56b253703f286253cadc701e01984090766e3c15
commit 56b253703f286253cadc701e01984090766e3c15
Author: Alex Coplan <alex.coplan@arm.com>
Date: Wed Sep 22 11:20:47 2021 +0100
c: Add missing fold in build_binary_op
In build_binary_op we call c_fully_fold on the address value operand
before building a replace_address_value node, since c_fully_fold (which
would otherwise be called later) can't fold inside replace_address_value
nodes. However, this didn't account for possible c_maybe_const_expr
nodes in the intcap expression itself. This adds a call to c_fully_fold
for the intcap operand.
gcc/c/ChangeLog:
* c-typeck.c (build_binary_op): Also call c_fully_fold on the
intcap operand before building a replace_address_value node.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/morello/intcap-fold-ice.c: New test.
Diff:
---
gcc/c/c-typeck.c | 3 ++-
gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c | 9 +++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 5b6c6e186af..30a082b3144 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -12962,8 +12962,9 @@ build_binary_op (location_t location, enum tree_code code,
intcap = convert (ic_type, intcap);
/* We can't fold inside REPLACE_ADDRESS_VALUE calls, so ensure
- we've folded the address value expression. */
+ we've folded the operands. */
ret = c_fully_fold (ret, false, NULL);
+ intcap = c_fully_fold (intcap, false, NULL);
ret = fold_build_replace_address_value_loc (location, intcap, ret);
}
diff --git a/gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c b/gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c
new file mode 100644
index 00000000000..95b73f8f7bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+/* This was ICEing due to a missing fold when building
+ replace_address_value nodes in the C frontend. */
+
+struct {
+ __uintcap_t a;
+} * b;
+void c() { long a = (b ? b->a : 0) + a; }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-01 9:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 9:16 [gcc(refs/vendors/ARM/heads/morello)] c: Add missing fold in build_binary_op Matthew Malcomson
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).