diff options
author | Richard Biener <rguenther@suse.de> | 2024-03-06 09:02:31 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2024-05-06 14:00:43 +0200 |
commit | c4795316b2d92c9edd3d86ffa11425c82d1e379c (patch) | |
tree | 34bddcb914b65fb1c1aa8f470d4f1d0b8e864bf2 | |
parent | 47cd06042237bf2d4f05b8355362bc038f6fa445 (diff) |
tree-optimization/114246 - invalid call argument from DSE
The following makes sure to strip type conversions added by
build_fold_addr_expr before placing the result in a call argument.
PR tree-optimization/114246
* tree-ssa-dse.cc (increment_start_addr): Strip useless
type conversions from the adjusted address.
* gcc.dg/torture/pr114246.c: New testcase.
(cherry picked from commit 0249744a9fe0775c2c895727aeebec4c59fd5f95)
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr114246.c | 11 | ||||
-rw-r--r-- | gcc/tree-ssa-dse.cc | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr114246.c b/gcc/testsuite/gcc.dg/torture/pr114246.c new file mode 100644 index 00000000000..eb20db594cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr114246.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-w" } */ + +int a, b; + +void +foo (void) +{ + __builtin_memcpy (&a, (char *)&b - 1, 2); + __builtin_memcpy (&a, &b, 1); +} diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc index e28eb88068a..779b518ff80 100644 --- a/gcc/tree-ssa-dse.cc +++ b/gcc/tree-ssa-dse.cc @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-loop-niter.h" #include "cfgloop.h" #include "tree-data-ref.h" +#include "tree-ssa.h" /* This file implements dead store elimination. @@ -643,6 +644,7 @@ increment_start_addr (gimple *stmt, tree *where, int increment) *where, build_int_cst (ptr_type_node, increment))); + STRIP_USELESS_TYPE_CONVERSION (*where); } /* STMT is builtin call that writes bytes in bitmap ORIG, some bytes are dead |