diff options
author | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-07-23 12:17:52 +0000 |
---|---|---|
committer | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-07-23 12:17:52 +0000 |
commit | b826233f9033cabe0b617627c7d3d62b56757eda (patch) | |
tree | 708b5d6ba2ce760f9aa54afab19127e158723c24 /gcc/tree-vect-loop.c | |
parent | 10adbe61291a0452434fe074c89047da0ab2ecd1 (diff) | |
download | gcc-b826233f9033cabe0b617627c7d3d62b56757eda.tar.gz |
Check TYPE_OVERFLOW_WRAPS for parloops reductions
2015-07-23 Tom de Vries <tom@codesourcery.com>
* tree-parloops.c (gather_scalar_reductions): Add arg to call to
vect_force_simple_reduction.
* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Same.
(vect_is_simple_reduction_1): Add and handle
need_wrapping_integral_overflow parameter.
(vect_is_simple_reduction, vect_force_simple_reduction): Add and pass
need_wrapping_integral_overflow parameter.
(vectorizable_reduction): Add arg to call to vect_is_simple_reduction.
* tree-vectorizer.h (vect_force_simple_reduction): Add parameter to decl.
* gcc.dg/autopar/outer-4.c: Add xfail.
* gcc.dg/autopar/outer-5.c: Same.
* gcc.dg/autopar/outer-6.c: Same.
* gcc.dg/autopar/reduc-2.c: Same.
* gcc.dg/autopar/reduc-2char.c: Same.
* gcc.dg/autopar/reduc-2short.c: Same.
* gcc.dg/autopar/reduc-8.c: Same.
* gcc.dg/autopar/uns-outer-4.c: New test.
* gcc.dg/autopar/uns-outer-5.c: New test.
* gcc.dg/autopar/uns-outer-6.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226107 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 9145dbf19e1..c31bfbdbad4 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -715,7 +715,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop) nested_cycle = (loop != LOOP_VINFO_LOOP (loop_vinfo)); reduc_stmt = vect_force_simple_reduction (loop_vinfo, phi, !nested_cycle, - &double_reduc); + &double_reduc, false); if (reduc_stmt) { if (double_reduc) @@ -2339,7 +2339,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple phi, gimple first_stmt) static gimple vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, bool check_reduction, bool *double_reduc, - bool modify) + bool modify, bool need_wrapping_integral_overflow) { struct loop *loop = (gimple_bb (phi))->loop_father; struct loop *vect_loop = LOOP_VINFO_LOOP (loop_info); @@ -2613,14 +2613,26 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, "reduction: unsafe fp math optimization: "); return NULL; } - else if (INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type) - && check_reduction) + else if (INTEGRAL_TYPE_P (type) && check_reduction) { - /* Changing the order of operations changes the semantics. */ - if (dump_enabled_p ()) - report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt, - "reduction: unsafe int math optimization: "); - return NULL; + if (TYPE_OVERFLOW_TRAPS (type)) + { + /* Changing the order of operations changes the semantics. */ + if (dump_enabled_p ()) + report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt, + "reduction: unsafe int math optimization" + " (overflow traps): "); + return NULL; + } + if (need_wrapping_integral_overflow && !TYPE_OVERFLOW_WRAPS (type)) + { + /* Changing the order of operations changes the semantics. */ + if (dump_enabled_p ()) + report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt, + "reduction: unsafe int math optimization" + " (overflow doesn't wrap): "); + return NULL; + } } else if (SAT_FIXED_POINT_TYPE_P (type) && check_reduction) { @@ -2749,10 +2761,12 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, static gimple vect_is_simple_reduction (loop_vec_info loop_info, gimple phi, - bool check_reduction, bool *double_reduc) + bool check_reduction, bool *double_reduc, + bool need_wrapping_integral_overflow) { return vect_is_simple_reduction_1 (loop_info, phi, check_reduction, - double_reduc, false); + double_reduc, false, + need_wrapping_integral_overflow); } /* Wrapper around vect_is_simple_reduction_1, which will modify code @@ -2761,10 +2775,12 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple phi, gimple vect_force_simple_reduction (loop_vec_info loop_info, gimple phi, - bool check_reduction, bool *double_reduc) + bool check_reduction, bool *double_reduc, + bool need_wrapping_integral_overflow) { return vect_is_simple_reduction_1 (loop_info, phi, check_reduction, - double_reduc, true); + double_reduc, true, + need_wrapping_integral_overflow); } /* Calculate cost of peeling the loop PEEL_ITERS_PROLOGUE times. */ @@ -5074,7 +5090,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, } gimple tmp = vect_is_simple_reduction (loop_vinfo, reduc_def_stmt, - !nested_cycle, &dummy); + !nested_cycle, &dummy, false); if (orig_stmt) gcc_assert (tmp == orig_stmt || GROUP_FIRST_ELEMENT (vinfo_for_stmt (tmp)) == orig_stmt); |