This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR44030
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 8 May 2010 15:10:34 +0200 (CEST)
- Subject: [PATCH] Fix PR44030
We have to be more careful with the NECESSARY flag.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2010-05-08 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44030
* tree-ssa-pre.c (eliminate): Copy NECESSARY flag. Set
NECESSARY flag if we propagate from a inserted expression.
* gcc.c-torture/compile/pr44030.c: New testcase.
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c (revision 159171)
--- gcc/tree-ssa-pre.c (working copy)
*************** eliminate (void)
*** 4351,4356 ****
--- 4351,4357 ----
sprime = fold_convert (TREE_TYPE (res), sprime);
stmt = gimple_build_assign (res, sprime);
SSA_NAME_DEF_STMT (res) = stmt;
+ gimple_set_plf (stmt, NECESSARY, gimple_plf (phi, NECESSARY));
gsi2 = gsi_after_labels (b);
gsi_insert_before (&gsi2, stmt, GSI_NEW_STMT);
*************** eliminate (void)
*** 4381,4388 ****
&& single_imm_use (lhs, &use_p, &use_stmt)
&& may_propagate_copy (USE_FROM_PTR (use_p), rhs))
{
! SET_USE (use_p, gimple_assign_rhs1 (stmt));
update_stmt (use_stmt);
}
/* If this is a store or a now unused copy, remove it. */
--- 4382,4392 ----
&& single_imm_use (lhs, &use_p, &use_stmt)
&& may_propagate_copy (USE_FROM_PTR (use_p), rhs))
{
! SET_USE (use_p, rhs);
update_stmt (use_stmt);
+ if (bitmap_bit_p (inserted_exprs, SSA_NAME_VERSION (lhs))
+ && TREE_CODE (rhs) == SSA_NAME)
+ gimple_set_plf (SSA_NAME_DEF_STMT (rhs), NECESSARY, true);
}
/* If this is a store or a now unused copy, remove it. */
Index: gcc/testsuite/gcc.c-torture/compile/pr44030.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr44030.c (revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr44030.c (revision 0)
***************
*** 0 ****
--- 1,28 ----
+ typedef int int32_t;
+ typedef unsigned int uint32_t;
+ static uint32_t
+ safe_sub_func_uint32_t_u_u (uint32_t ui1, uint32_t ui2)
+ {
+ return ui1 - ui2;
+ }
+
+ int32_t l_105[7];
+
+ int32_t g_4;
+ int32_t *g_54 = &g_4;
+ int32_t *
+ func (int32_t p_73, int32_t * p_74, int32_t p_75, int32_t * *p_76,
+ int32_t * *p_77)
+ {
+ lbl_110:for (g_4 = 0; g_4; g_4 = 1)
+ {
+ }
+ for (p_75 = -28; p_75; p_75 = safe_sub_func_uint32_t_u_u (p_75, 1))
+ {
+ if (g_4)
+ goto lbl_110;
+ *g_54 = 0;
+ }
+ return &l_105[5];
+ }
+