[all-commits] [llvm/llvm-project] 1d6a67: [LoopUnroll] Make use of MaxTripCount for loops wi...
XiangZhang via All-commits
all-commits at lists.llvm.org
Fri Dec 8 03:43:24 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1d6a678591076f316bfcaa03a55beba20406dc00
https://github.com/llvm/llvm-project/commit/1d6a678591076f316bfcaa03a55beba20406dc00
Author: XiangZhang <xiang.zhang at iluvatar.com>
Date: 2023-12-08 (Fri, 08 Dec 2023)
Changed paths:
M llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
A llvm/test/Transforms/LoopUnroll/loop-branch-folding.ll
Log Message:
-----------
[LoopUnroll] Make use of MaxTripCount for loops with "#pragma unroll" (#74703)
Fix loop unroll fail caused by branches folding.
For example:
SimplifyCFG foldloop branches then cause loop unroll failed for "#program unroll" loop.
```
#program unroll
for (int I = 0; I < ConstNum; ++I) { // folding "I < ConstNum" and "Cond2"
if (Cond2) {
break;
}
xxx loop body;
}
```
The pragma unroll metadata only takes effect if there is an exact trip
count, but not if there is an upper bound trip count. This patch make it
work with an upper bound trip count as well in shouldPragmaUnroll().
Loop unroll is important in stack nervous devices (e.g. GPU, and that is
why a lot of GPU code mark loop with "#program unroll").
It usually much simplify the address (offset) calculations in old
iterations, then we can do a lot of others optimizations, e.g, SROA, for
these simplifed address (escape alloca the whole aggregates).
More information about the All-commits
mailing list