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 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140411/3e2ceac3/attachment.html>
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 readonlyThe 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>
Here, The function ’select_value’, which is an external function, only write to the first parameter and other parameters are readonly and no global value writing. As what I know, we didn't have an attribute for this case to indict only writing to the first actual parameter. We should mark the first parameter as Mod, others as Ref and let cse work for readonly arguments. Pls kindly let me know If you know any way to mark the function to ONLY kill the first parameter for the general optimization. thanks xiaoyong Subject: Re: [LLVMdev] llvm cse optimization From: nrotem at apple.com Date: Fri, 11 Apr 2014 10:25:57 -0700 CC: llvmdev at cs.uiuc.edu To: xiaoyongliu at outlook.com 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/1cc39e95/attachment.html>
Possibly Parallel Threads
- varargs, the x86, and clang
- set_table_name and self.table_name
- SelectionDAG::LegalizeTypes is very slow in 3.1 version
- How to know the sub-class of a Value class?
- RFC: [DebugInfo] Improving Debug Information in LLVM to Recover Optimized-out Function Parameters