* [PATCH] tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR
@ 2023-02-16 7:29 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-02-16 7:29 UTC (permalink / raw)
To: gcc-patches
The following fixes a checking ICE by choosing a more appropriate
type for an ADDR_EXPR built by forwprop.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/108791
* tree-ssa-forwprop.cc (optimize_vector_load): Build
the ADDR_EXPR of a TARGET_MEM_REF using a more meaningful
type.
* gcc.dg/torture/pr108791.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr108791.c | 9 +++++++++
gcc/tree-ssa-forwprop.cc | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr108791.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr108791.c b/gcc/testsuite/gcc.dg/torture/pr108791.c
new file mode 100644
index 00000000000..c1c1cb22aad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr108791.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+int f (int *a(), int *b, int *c, int *d)
+{
+ int s = 0;
+ for (int *i = (int *)a; i < b; ++i, ++c)
+ s += *c * d[*i];
+ return s;
+}
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 0841a739fe1..03fe0a3f6df 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -3299,7 +3299,8 @@ optimize_vector_load (gimple_stmt_iterator *gsi)
{
if (TREE_CODE (TREE_OPERAND (load_rhs, 0)) == ADDR_EXPR)
mark_addressable (TREE_OPERAND (TREE_OPERAND (load_rhs, 0), 0));
- tree tem = make_ssa_name (TREE_TYPE (TREE_OPERAND (load_rhs, 0)));
+ tree ptrtype = build_pointer_type (TREE_TYPE (load_rhs));
+ tree tem = make_ssa_name (ptrtype);
gimple *new_stmt
= gimple_build_assign (tem, build1 (ADDR_EXPR, TREE_TYPE (tem),
unshare_expr (load_rhs)));
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-16 7:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 7:29 [PATCH] tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR Richard Biener
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).