From 6cc61b5a37376a87637c1ada009976ae59e134f9 Mon Sep 17 00:00:00 2001 From: Robin Dapp Date: Mon, 6 Mar 2017 12:43:33 +0000 Subject: [PATCH] S/390: Disable vectorization for loops with few iterations The following patch defines the PARAM_MIN_VECT_LOOP_BOUND parameter in the s390 backend. It helps with the vectorization epilogue problem described here [1]. I see an overall performance increase of > 1% in SPECfp2006, yet some cases like cactusADM regress. This seems to be caused by the vectorizer creating an epilogue guard for one more iteration than before, which, in turn, causes e.g. predcom to run on the epilogue that it used to ignore before ("Loop iterates only 1 time, nothing to do."). Subsequent, minor, effects cause an eventual slowdown. Until the reason for the bad epilogue code is understood, this patch mitigates the problem. When investigating the issue, I stumbled across an attempt to vectorize the epilogue itself as well as combine it with the vectorized loop in addition to vector masking [2]. A similar approach might also help here. My original observation of high register pressure within the epilogue still stands. In this specific case, it would most likely suffice to save all registers once, run the epilogue and restore the registers. I'm pretty sure this would be faster than the "spill fest" that's currently happening. Regards Robin [1] https://gcc.gnu.org/ml/gcc/2017-01/msg00234.html [2] https://gcc.gnu.org/ml/gcc-patches/2016-05/msg01562.html gcc/ChangeLog: 2017-03-06 Robin Dapp * config/s390/s390.c (s390_option_override_internal): Set PARAM_MIN_VECT_LOOP_BOUND From-SVN: r245918 --- gcc/ChangeLog | 5 +++++ gcc/config/s390/s390.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8393f03aec4..1176ec3e465 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-03-06 Robin Dapp + + * config/s390/s390.c (s390_option_override_internal): Set + PARAM_MIN_VECT_LOOP_BOUND + 2017-03-06 Robin Dapp * config/s390/s390.c (s390_asm_output_function_label): Use nopr %r0. diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index e8265c6add5..e7ab128252b 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -14679,6 +14679,10 @@ s390_option_override_internal (bool main_args_p, opts->x_param_values, opts_set->x_param_values); + maybe_set_param_value (PARAM_MIN_VECT_LOOP_BOUND, 2, + opts->x_param_values, + opts_set->x_param_values); + /* Call target specific restore function to do post-init work. At the moment, this just sets opts->x_s390_cost_pointer. */ s390_function_specific_restore (opts, NULL); -- 2.30.2