rtl-optimization/118298 - constant iteration loops and #pragma unroll

Message ID 20250107141428.2C21E3858282@sourceware.org
State New
Headers
Series rtl-optimization/118298 - constant iteration loops and #pragma unroll |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Richard Biener Jan. 7, 2025, 2:09 p.m. UTC
  When the RTL unroller handles constant iteration loops it bails out
prematurely when heuristics wouldn't apply any unrolling before
checking #pragma unroll.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR rtl-optimization/118298
	* loop-unroll.cc (decide_unroll_constant_iterations): Honor
	loop->unroll even if the loop is too big for heuristics.
---
 gcc/loop-unroll.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/loop-unroll.cc b/gcc/loop-unroll.cc
index 2bd6e888b26..b4952055318 100644
--- a/gcc/loop-unroll.cc
+++ b/gcc/loop-unroll.cc
@@ -372,7 +372,8 @@  decide_unroll_constant_iterations (class loop *loop, int flags)
     nunroll = targetm.loop_unroll_adjust (nunroll, loop);
 
   /* Skip big loops.  */
-  if (nunroll <= 1)
+  if (nunroll <= 1
+      && !(loop->unroll > 1 && loop->unroll < USHRT_MAX))
     {
       if (dump_file)
 	fprintf (dump_file, ";; Not considering loop, is too big\n");