Do not use doloop pattern with pragma Unroll
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 23 Oct 2020 07:51:46 +0000 (09:51 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 23 Oct 2020 07:58:33 +0000 (09:58 +0200)
This fixes the following Ada failure on 64-bit PowerPC:

-FAIL: gnat.dg/unroll4.adb scan-rtl-dump-times loop2_unroll "optimized:
loop unrolled 7 times" 2

The IVOPTS pass detects a doloop pattern and consequently discombobulates
the loop sufficiently as to make it hard for the RTL unrolling pass to
compute the best number of iterations.

gcc/ChangeLog:
* tree-ssa-loop-ivopts.c (analyze_and_mark_doloop_use): Bail out if
the loop is subject to a pragma Unroll with no specific count.

gcc/tree-ssa-loop-ivopts.c

index 5acf044161c07b9b799a2a650f14dc5ddd55264c..da04dd5ba0acff7cc772d760ac69c38d41e25be6 100644 (file)
@@ -7947,6 +7947,9 @@ analyze_and_mark_doloop_use (struct ivopts_data *data)
   if (!flag_branch_on_count_reg)
     return;
 
+  if (data->current_loop->unroll == USHRT_MAX)
+    return;
+
   if (!generic_predict_doloop_p (data))
     return;