aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-10-06 11:48:03 +0200
committerRichard Biener <rguenther@suse.de>2022-10-06 14:20:04 +0200
commit0af8d957d5911fc7659b4174cfc2213289bbed23 (patch)
treebe8272ebd4ca393c1ff8014695c2ab64e440641a /gcc/expr.cc
parent33b93ac3f2fb68a2da0d42fd692fe59533f7a84f (diff)
downloadgcc-0af8d957d5911fc7659b4174cfc2213289bbed23.zip
gcc-0af8d957d5911fc7659b4174cfc2213289bbed23.tar.gz
gcc-0af8d957d5911fc7659b4174cfc2213289bbed23.tar.bz2
middle-end/107115 - avoid bogus redundant store removal during RTL expansion
The following preserves the (premature) redundant store removal done in store_expr by appropriately guarding it with mems_same_for_tbaa_p. The testcase added needs scheduling disabled for now since there's a similar bug there still present. PR middle-end/107115 * expr.cc (store_expr): Check mems_same_for_tbaa_p before eliding a seemingly redundant store. * gcc.dg/torture/pr107115.c: New testcase.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r--gcc/expr.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 80bb1b8..ba627f1 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -6207,7 +6207,9 @@ store_expr (tree exp, rtx target, int call_param_p,
if ((! rtx_equal_p (temp, target)
|| (temp != target && (side_effects_p (temp)
- || side_effects_p (target))))
+ || side_effects_p (target)
+ || (MEM_P (temp)
+ && !mems_same_for_tbaa_p (temp, target)))))
&& TREE_CODE (exp) != ERROR_MARK
/* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
but TARGET is not valid memory reference, TEMP will differ