Skip to content

Commit 0249744

Browse files
committed
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.
1 parent 1157d5d commit 0249744

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* { dg-do compile } */
2+
/* { dg-additional-options "-w" } */
3+
4+
int a, b;
5+
6+
void
7+
foo (void)
8+
{
9+
__builtin_memcpy (&a, (char *)&b - 1, 2);
10+
__builtin_memcpy (&a, &b, 1);
11+
}

gcc/tree-ssa-dse.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see
4949
#include "cfgloop.h"
5050
#include "tree-data-ref.h"
5151
#include "internal-fn.h"
52+
#include "tree-ssa.h"
5253

5354
/* This file implements dead store elimination.
5455
@@ -658,6 +659,7 @@ increment_start_addr (gimple *stmt, tree *where, int increment)
658659
*where,
659660
build_int_cst (ptr_type_node,
660661
increment)));
662+
STRIP_USELESS_TYPE_CONVERSION (*where);
661663
}
662664

663665
/* STMT is builtin call that writes bytes in bitmap ORIG, some bytes are dead

0 commit comments

Comments
 (0)