Skip to content

Commit c479531

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. (cherry picked from commit 0249744)
1 parent 47cd060 commit c479531

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
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
4848
#include "tree-ssa-loop-niter.h"
4949
#include "cfgloop.h"
5050
#include "tree-data-ref.h"
51+
#include "tree-ssa.h"
5152

5253
/* This file implements dead store elimination.
5354
@@ -643,6 +644,7 @@ increment_start_addr (gimple *stmt, tree *where, int increment)
643644
*where,
644645
build_int_cst (ptr_type_node,
645646
increment)));
647+
STRIP_USELESS_TYPE_CONVERSION (*where);
646648
}
647649

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

0 commit comments

Comments
 (0)