aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-02-15 14:00:21 +0100
committerRichard Biener <rguenther@suse.de>2023-02-16 08:29:44 +0100
commit441c466fd4d8b9afd99f585f7c4bfade911c4652 (patch)
tree9de47cdf76bd117fdcd13dff1e2e94dc323f3c6b /gcc
parent384dedaf65db115e9795438d787bc8bd84bb6777 (diff)
downloadgcc-441c466fd4d8b9afd99f585f7c4bfade911c4652.zip
gcc-441c466fd4d8b9afd99f585f7c4bfade911c4652.tar.gz
gcc-441c466fd4d8b9afd99f585f7c4bfade911c4652.tar.bz2
tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR
The following fixes a checking ICE by choosing a more appropriate type for an ADDR_EXPR built by forwprop. 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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr108791.c9
-rw-r--r--gcc/tree-ssa-forwprop.cc3
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr108791.c b/gcc/testsuite/gcc.dg/torture/pr108791.c
new file mode 100644
index 0000000..c1c1cb2
--- /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 0841a73..03fe0a3 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)));