gcc/PR92429-do-not-fold-when-updating.patch
xiezhiheng ae8eb7c877 [Upload patch] Upload patches to add new features
and fix bugs

- add-fp-model-options.patch: New file
- enable-simd-math.patch: Enable simd math library in C and Fortran
- fix-CTOR-vectorization.patch: New file
- fix-range-set-by-vectorization-on-niter-IVs.patch: New file
- medium-code-mode.patch: Fix bugs when used with fpic
- optabs-Dont-use-scalar-conversions-for-vectors.patch: New file
- PR92429-do-not-fold-when-updating.patch: New file
- redundant-loop-elimination.patch: Fix some programming specifications
- fix-ICE-in-vect.patch: New file
- Fix-type-mismatch-in-SLPed-constructors.patch: New file
- add-check-for-pressure-in-sche1.patch: New file
- revert-moutline-atomics.patch: New file
- fix-ICE-in-eliminate-stmt.patch: New file
- revise-type-before-build-MULT.patch: New file
- Simplify-X-C1-C2.patch: New file
- gcc.spec: Add new patches
2021-04-29 10:30:11 +08:00

71 lines
2.7 KiB
Diff

This backport contains 1 patch from gcc main stream tree.
The commit id of these patchs list as following in the order of time.
0001-PR-tree-optimization-92429-do-not-fold-when-updating.patch
f7dff7699fd70d3b8c3e637818e18c86f93ccfec
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 4d5e0494511..6e6df0bfdb8 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -1934,7 +1934,8 @@ number_of_iterations_cond (class loop *loop,
tree
simplify_replace_tree (tree expr, tree old, tree new_tree,
- tree (*valueize) (tree, void*), void *context)
+ tree (*valueize) (tree, void*), void *context,
+ bool do_fold)
{
unsigned i, n;
tree ret = NULL_TREE, e, se;
@@ -1966,7 +1967,7 @@ simplify_replace_tree (tree expr, tree old, tree new_tree,
for (i = 0; i < n; i++)
{
e = TREE_OPERAND (expr, i);
- se = simplify_replace_tree (e, old, new_tree, valueize, context);
+ se = simplify_replace_tree (e, old, new_tree, valueize, context, do_fold);
if (e == se)
continue;
@@ -1976,7 +1977,7 @@ simplify_replace_tree (tree expr, tree old, tree new_tree,
TREE_OPERAND (ret, i) = se;
}
- return (ret ? fold (ret) : expr);
+ return (ret ? (do_fold ? fold (ret) : ret) : expr);
}
/* Expand definitions of ssa names in EXPR as long as they are simple
diff --git a/gcc/tree-ssa-loop-niter.h b/gcc/tree-ssa-loop-niter.h
index 621e2c2e28d..eb8d1579479 100644
--- a/gcc/tree-ssa-loop-niter.h
+++ b/gcc/tree-ssa-loop-niter.h
@@ -58,7 +58,7 @@ extern void free_numbers_of_iterations_estimates (class loop *);
extern void free_numbers_of_iterations_estimates (function *);
extern tree simplify_replace_tree (tree, tree,
tree, tree (*)(tree, void *) = NULL,
- void * = NULL);
+ void * = NULL, bool do_fold = true);
extern void substitute_in_loop_info (struct loop *, tree, tree);
#endif /* GCC_TREE_SSA_LOOP_NITER_H */
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 8e318a037a7..e5fb434bd4e 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -8434,8 +8434,13 @@ update_epilogue_loop_vinfo (class loop *epilogue, tree advance)
gimple_set_op (stmt, j, *new_op);
else
{
+ /* PR92429: The last argument of simplify_replace_tree disables
+ folding when replacing arguments. This is required as
+ otherwise you might end up with different statements than the
+ ones analyzed in vect_loop_analyze, leading to different
+ vectorization. */
op = simplify_replace_tree (op, NULL_TREE, NULL_TREE,
- &find_in_mapping, &mapping);
+ &find_in_mapping, &mapping, false);
gimple_set_op (stmt, j, op);
}
}