+ phis = VEC_alloc (gimple, heap, 3);
+ /* Find the loop-closed-use at the loop exit of the original scalar
+ result. (The reduction result is expected to have two immediate uses,
+ one at the latch block, and one at the loop exit). For double
+ reductions we are looking for exit phis of the outer loop. */
+ FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
+ {
+ if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p))))
+ VEC_safe_push (gimple, heap, phis, USE_STMT (use_p));
+ else
+ {
+ if (double_reduc && gimple_code (USE_STMT (use_p)) == GIMPLE_PHI)
+ {
+ tree phi_res = PHI_RESULT (USE_STMT (use_p));
+
+ 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))))
+ VEC_safe_push (gimple, heap, phis,
+ USE_STMT (phi_use_p));
+ }
+ }
+ }
+ }
+
+ FOR_EACH_VEC_ELT (gimple, phis, i, exit_phi)
+ {