Xiangyang Guo via llvm-dev
2015-Dec-01 17:30 UTC
[llvm-dev] LICM doesn't work for IntrReadMem intrinsic function
Hi, All, Suppose I define one memory read only intrinsic function "foo" in Intrinsics.td like this def int_foo : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrReadMem]>; Suppose I have the following IR, which means the intrinsic function "foo" is called 10 times in a loop. Since the parameters of function "foo" are invariant and the function "foo" is defined as "IntrReadMem". I assume the '-licm' can move the function call 'foo' out of the loop body. However, after I use "opt test.ll -basicaa -licm -S", the function call 'foo' is still inside the loop body. Do I misunderstand something here? Any suggestions are appreciated. Thanks a lot. ; Function Attrs: uwtable define i32 @_Z5func1i(i32 %a) #0 { br label %1 ; <label>:1 ; preds = %3, %0 %ret.0 = phi i32 [ 0, %0 ], [ %4, %3 ] %i.0 = phi i32 [ 0, %0 ], [ %5, %3 ] %2 = icmp slt i32 %i.0, 10 br i1 %2, label %3, label %6 ; <label>:3 ; preds = %1 %4 = call i32 @llvm.foo(i32 %a, i32 3) %5 = add nsw i32 %i.0, 1 br label %1 ; <label>:6 ; preds = %1 ret i32 %ret.0 } ; Function Attrs: nounwind readonly declare i32 @llvm.foo(i32, i32) #1 Regards, Xiangyang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151201/c2e471a9/attachment.html>
via llvm-dev
2015-Dec-01 17:48 UTC
[llvm-dev] LICM doesn't work for IntrReadMem intrinsic function
> On Dec 1, 2015, at 9:30 AM, Xiangyang Guo via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, All, > > Suppose I define one memory read only intrinsic function "foo" in Intrinsics.td like this > > def int_foo : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrReadMem]>; > > Suppose I have the following IR, which means the intrinsic function "foo" is called 10 times in a loop. Since the parameters of function "foo" are invariant and the function "foo" is defined as "IntrReadMem". I assume the '-licm' can move the function call 'foo' out of the loop body. However, after I use "opt test.ll -basicaa -licm -S", the function call 'foo' is still inside the loop body. Do I misunderstand something here? Any suggestions are appreciated. Thanks a lot.Does it work if you call -loop-rotate first? Loop unrolling requires loops to be in canonicalized rotated form first, so I wouldn’t be surprised if LICM does as well. —escha
Xiangyang Guo via llvm-dev
2015-Dec-01 18:16 UTC
[llvm-dev] LICM doesn't work for IntrReadMem intrinsic function
Thanks for your reply, escha, Yes, -loop-rorate makes it work. Regards, Xiangyang 2015-12-01 12:48 GMT-05:00 <escha at apple.com>:> > > On Dec 1, 2015, at 9:30 AM, Xiangyang Guo via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > > > Hi, All, > > > > Suppose I define one memory read only intrinsic function "foo" in > Intrinsics.td like this > > > > def int_foo : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], > [IntrReadMem]>; > > > > Suppose I have the following IR, which means the intrinsic function > "foo" is called 10 times in a loop. Since the parameters of function "foo" > are invariant and the function "foo" is defined as "IntrReadMem". I assume > the '-licm' can move the function call 'foo' out of the loop body. However, > after I use "opt test.ll -basicaa -licm -S", the function call 'foo' is > still inside the loop body. Do I misunderstand something here? Any > suggestions are appreciated. Thanks a lot. > > Does it work if you call -loop-rotate first? Loop unrolling requires loops > to be in canonicalized rotated form first, so I wouldn’t be surprised if > LICM does as well. > > —escha-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151201/cb989800/attachment.html>
Apparently Analagous Threads
- LICM doesn't work for IntrReadMem intrinsic function
- LICM doesn't work for IntrReadMem intrinsic function
- add intrinsic function support for customized backend
- add intrinsic function support for customized backend
- define intrinsic function with pointer-typed parameter