[PATCH] Fix PR58539
Richard Biener
rguenther@suse.de
Thu Sep 26 11:58:00 GMT 2013
The vectorizer does not honor the fact that debug statements
do not participate in loop-closed-SSA construction and thus
a SSA name can have outside loop uses that are not in the
loop-closed PHI node but in a debug statement.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard.
2013-09-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/58539
* tree-vect-loop.c (vect_create_epilog_for_reduction): Honor
the fact that debug statements are not taking part in loop-closed
SSA construction.
* gcc.dg/torture/pr58539.c: New testcase.
Index: gcc/tree-vect-loop.c
===================================================================
*** gcc/tree-vect-loop.c (revision 202883)
--- gcc/tree-vect-loop.c (working copy)
*************** vect_finalize_reduction:
*** 4411,4417 ****
result. (The reduction result is expected to have two immediate uses -
one at the latch block, and one at the loop exit). */
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
! if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p))))
phis.safe_push (USE_STMT (use_p));
/* While we expect to have found an exit_phi because of loop-closed-ssa
--- 4411,4418 ----
result. (The reduction result is expected to have two immediate uses -
one at the latch block, and one at the loop exit). */
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
! if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p)))
! && !is_gimple_debug (USE_STMT (use_p)))
phis.safe_push (USE_STMT (use_p));
/* While we expect to have found an exit_phi because of loop-closed-ssa
*************** vect_finalize_reduction:
*** 4541,4547 ****
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
{
if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p))))
! phis.safe_push (USE_STMT (use_p));
else
{
if (double_reduc && gimple_code (USE_STMT (use_p)) == GIMPLE_PHI)
--- 4542,4551 ----
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
{
if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p))))
! {
! if (!is_gimple_debug (USE_STMT (use_p)))
! phis.safe_push (USE_STMT (use_p));
! }
else
{
if (double_reduc && gimple_code (USE_STMT (use_p)) == GIMPLE_PHI)
*************** vect_finalize_reduction:
*** 4551,4557 ****
FOR_EACH_IMM_USE_FAST (phi_use_p, phi_imm_iter, phi_res)
{
if (!flow_bb_inside_loop_p (loop,
! gimple_bb (USE_STMT (phi_use_p))))
phis.safe_push (USE_STMT (phi_use_p));
}
}
--- 4555,4562 ----
FOR_EACH_IMM_USE_FAST (phi_use_p, phi_imm_iter, phi_res)
{
if (!flow_bb_inside_loop_p (loop,
! gimple_bb (USE_STMT (phi_use_p)))
! && !is_gimple_debug (USE_STMT (phi_use_p)))
phis.safe_push (USE_STMT (phi_use_p));
}
}
Index: gcc/testsuite/gcc.dg/torture/pr58539.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr58539.c (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr58539.c (working copy)
***************
*** 0 ****
--- 1,20 ----
+ /* { dg-do compile } */
+ /* { dg-options "-g" } */
+
+ int a, b;
+
+ extern void baz (int);
+
+ int foo (int p)
+ {
+ return p ? p : 1;
+ }
+
+ void bar ()
+ {
+ int *c = &a, *d = &a;
+ for (b = 0; b < 12; b++)
+ *d |= 1;
+ foo (*c);
+ baz (*c && 1);
+ }
More information about the Gcc-patches
mailing list