Skip to content
Snippets Groups Projects
  • Mark Heffernan's avatar
    1476822d
    Add new llvm.loop.unroll.enable metadata for use with "#pragma unroll". · 1476822d
    Mark Heffernan authored
    This change adds the new unroll metadata "llvm.loop.unroll.enable" which directs
    the optimizer to unroll a loop fully if the trip count is known at compile time, and
    unroll partially if the trip count is not known at compile time. This differs from
    "llvm.loop.unroll.full" which explicitly does not unroll a loop if the trip count is not
    known at compile time
    
    With this change "#pragma unroll" generates "llvm.loop.unroll.enable" rather than
    "llvm.loop.unroll.full" metadata. This changes the semantics of "#pragma unroll" slightly
    to mean "unroll aggressively (fully or partially)" rather than "unroll fully or not at all".
    
    The motivating example for this change was some internal code with a loop marked
    with "#pragma unroll" which only sometimes had a compile-time trip count depending
    on template magic. When the trip count was a compile-time constant, everything works
    as expected and the loop is fully unrolled. However, when the trip count was not a
    compile-time constant the "#pragma unroll" explicitly disabled unrolling of the loop(!).
    Removing "#pragma unroll" caused the loop to be unrolled partially which was desirable
    from a performance perspective.
    
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244467 91177308-0d34-0410-b5e6-96231b3b80d8
    1476822d
    History
    Add new llvm.loop.unroll.enable metadata for use with "#pragma unroll".
    Mark Heffernan authored
    This change adds the new unroll metadata "llvm.loop.unroll.enable" which directs
    the optimizer to unroll a loop fully if the trip count is known at compile time, and
    unroll partially if the trip count is not known at compile time. This differs from
    "llvm.loop.unroll.full" which explicitly does not unroll a loop if the trip count is not
    known at compile time
    
    With this change "#pragma unroll" generates "llvm.loop.unroll.enable" rather than
    "llvm.loop.unroll.full" metadata. This changes the semantics of "#pragma unroll" slightly
    to mean "unroll aggressively (fully or partially)" rather than "unroll fully or not at all".
    
    The motivating example for this change was some internal code with a loop marked
    with "#pragma unroll" which only sometimes had a compile-time trip count depending
    on template magic. When the trip count was a compile-time constant, everything works
    as expected and the loop is fully unrolled. However, when the trip count was not a
    compile-time constant the "#pragma unroll" explicitly disabled unrolling of the loop(!).
    Removing "#pragma unroll" caused the loop to be unrolled partially which was desirable
    from a performance perspective.
    
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244467 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.