[LLVMdev] help: bypass a type of loop optimization in LLVM front end
hilbert Wang
huaibo.wang at gmail.com
Sat Apr 26 02:31:43 PDT 2014
Tim and guys,
let's look at the following example:
============
unsigned char f;
void main()
{
for(unsigned char i = 0; i < f;i ++)
asm("nop");
}
================
the optimized LLVM code was as follows:
====================
1.define void @main() nounwind {
2.entry:
3. %0 = load i8* @f, align 1, !tbaa !0
4. %cmp4 = icmp eq i8 %0, 0
5. br i1 %cmp4, label %for.end, label %for.body
6
7.for.body: ; preds = %entry,
%for.body
8. %i.05 = phi i8 [ %inc, %for.body ], [ 0, %entry ]
9. tail call void asm sideeffect "nop", ""() nounwind, !srcloc !2
10. %inc = add i8 %i.05, 1
11. %1 = load i8* @f, align 1, !tbaa !0
12. %cmp = icmp ult i8 %inc, %1
13. br i1 %cmp, label %for.body, label %for.end
14.
15.for.end: ; preds = %for.body,
%entry
16. ret void
17.}
===============
>From line 3 to 5, whether f is equal to 0 is checked first.
because the profit of the optimization did not make sense for the target.
why it did not make sense in our target was out the scope of the post.
I was asking for help, can I prevent this optimization in command line or
which function i need to work on to skip such optimization in front end?
thanks,
cheers,
hilbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140426/41e432d7/attachment.html>
More information about the llvm-dev
mailing list