[llvm-dev] Optimize from 'for' to 'do-while' when setting #pragma clang loop min(1)

Finkel, Hal J. via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 15 19:50:57 PDT 2018

Hi, Klarke,

Does adding __builtin_assume(n > 0); before the loop currently accomplish what you're trying to do?


On 10/15/2018 09:37 PM, Qianyi (Compiler) via llvm-dev wrote:
To whom it may concern,

I’m implementing one pragma to optimize “for” loop.
We assume the loop will run at least 1 times when we set following pragma:
#pragma clang loop min(1)
for(i = 0; i < n; I ++)
Then we can remove the first branch which go to exit block when “n < =0”.

This is one picture which show llvm how to do loop rotation.
[cid:part1.E82CD81F.F5E8AB60 at anl.gov]

Is it the proper place(LoopRotation.cpp) to implement my feature?
Or is there more suitable place to do it?

Best regards,

LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>

Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181016/eff0ff04/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 19260 bytes
Desc: image001.jpg
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181016/eff0ff04/attachment.jpg>

More information about the llvm-dev mailing list