[LLVMdev] llvm cse optimization
Nadav Rotem
nrotem at apple.com
Fri Apr 11 10:25:57 PDT 2014
On Apr 11, 2014, at 10:13 AM, xiaoyong liu <xiaoyongliu at outlook.com> wrote:
> I'm working on the across the subprogram call optimization, and let's say the following llvm IR,
>
> @ng0 = internal global [2 x i32] [i32 2, i32 0], align 4
>
> %t7 = alloca [16 x i8], align 16
> %add.ptr = getelementptr inbounds i8* %t1, i64 40
> %call = call i8* @handle_value(i8* %add.ptr, i32 3) #3
> %arraydecay = getelementptr inbounds [8 x i8]* %t3, i64 0, i64 0
> %arraydecay1 = getelementptr inbounds [16 x i8]* %t4, i64 0, i64 0
> call void @select_value(i8* %arraydecay, i32 1, i32 1, i8* %call, i8* %arraydecay1, i8* null, i32 1, i32 2, i32 1, i8* bitcast ([2 x i32]* @ng0 to i8*), i32 32, i32 1) #3
> %call3 = call i8* @handle_value(i8* %add.ptr, i32 3) #3
>
> ; Function Attrs: nounwind readonly
> declare i8* @handle_value(i8* nocapture, i32) #1
> ; Function Attrs: nounwind
> declare void @select_value(i8*, i32, i32, i8* nocapture readonly, i8* nocapture readonly, i8*, i32, i32, i32, i8*, i32, i32) #2 //select value will only write to the first parameter, other parameter is readonly
The function ’select_value’ is not marked as *not* having side effects. They compiler has to assume that it could write to memory or print to the screen so it can’t merge them.
>
> For the above case, the second handle_value function call should be replaced with %call with cse or gvn optimization.
>
> Is anything I can do to optimize this case?
>
> thanks
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140411/7d2032db/attachment.html>
More information about the llvm-dev
mailing list