[PATCH] Fix bug causing loop unrolling to be disabled in some cases for loops with '#pragma clang loop unroll_count(N)"

Hal Finkel hfinkel at anl.gov
Thu Jul 24 15:02:48 PDT 2014


In true LLVM style, I ask for a 40-line test case for your one-line change ;)

 -Hal

----- Original Message -----
> From: "Mark Heffernan" <meheff at google.com>
> To: meheff at google.com, hfinkel at anl.gov
> Cc: llvm-commits at cs.uiuc.edu
> Sent: Thursday, July 24, 2014 4:59:24 PM
> Subject: [PATCH] Fix bug causing loop unrolling to be disabled in some cases for loops with '#pragma clang loop
> unroll_count(N)"
> 
> Hi hfinkel,
> 
> After unrolling a loop with llvm.loop.unroll.count metadata (unroll
> factor hint) the loop unroller replaces the llvm.loop.unroll.count
> metadata with llvm.loop.unroll.disable metadata to prevent any
> subsequent unrolling passes from unrolling more than the hint
> indicates.  However, if the unroll count metadata is shared between
> loops then unrolling for these other loops will also be disabled.
>  This small patch fixes that problem by adding the
> llvm.loop.unroll.disable metadata to only the loop which was just
> unrolled.
> 
> http://reviews.llvm.org/D4662
> 
> Files:
>   lib/Transforms/Scalar/LoopUnrollPass.cpp
> 
> Index: lib/Transforms/Scalar/LoopUnrollPass.cpp
> ===================================================================
> --- lib/Transforms/Scalar/LoopUnrollPass.cpp
> +++ lib/Transforms/Scalar/LoopUnrollPass.cpp
> @@ -302,7 +302,6 @@
>    // Set operand 0 to refer to the loop id itself.
>    NewLoopID->replaceOperandWith(0, NewLoopID);
>    L->setLoopID(NewLoopID);
> -  LoopID->replaceAllUsesWith(NewLoopID);
>  }
>  
>  unsigned LoopUnroll::selectUnrollCount(
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list