diff options
author | Richard Biener <rguenther@suse.de> | 2025-05-30 13:47:55 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2025-06-06 09:53:11 +0200 |
commit | 09884fa0f90da67915245622254cdfb947b87d37 (patch) | |
tree | abe5f7883a4e77126a19dc1e49c02192d9e9e52d /gcc/tree-ssa-phiopt.cc | |
parent | 44792a6c4253f9a5b322797ef73b9c347c223545 (diff) | |
download | gcc-09884fa0f90da67915245622254cdfb947b87d37.zip gcc-09884fa0f90da67915245622254cdfb947b87d37.tar.gz gcc-09884fa0f90da67915245622254cdfb947b87d37.tar.bz2 |
tree-optimization/120341 - stores into STRING_CSTs can trap
The following fixes conditional store elimination and store motion
so they consider stores to STRING_CSTs as trapping.
PR tree-optimization/120341
* tree-ssa-loop-im.cc (can_sm_ref_p): STRING_CSTs are readonly.
* tree-ssa-phiopt.cc (cond_store_replacement): Likewise.
* gcc.dg/torture/pr120341-1.c: New testcase.
* gcc.dg/torture/pr120341-2.c: Likewise.
(cherry picked from commit 02c58bc4b0885f5b6f50033da35768ebe6c4a030)
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
-rw-r--r-- | gcc/tree-ssa-phiopt.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 7f3390b..aaebae6 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -3565,8 +3565,9 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, /* tree_could_trap_p is a predicate for rvalues, so check for readonly memory explicitly. */ || ((base = get_base_address (lhs)) - && DECL_P (base) - && TREE_READONLY (base))) + && ((DECL_P (base) + && TREE_READONLY (base)) + || TREE_CODE (base) == STRING_CST))) return false; } |