<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 11, 2014, at 10:13 AM, xiaoyong liu <<a href="mailto:xiaoyongliu@outlook.com">xiaoyongliu@outlook.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr">I'm working on the across the subprogram call optimization, and let's say the following llvm IR,<br> <br> @ng0 = internal global [2 x i32] [i32 2, i32 0], align 4<br> <br>  %t7 = alloca [16 x i8], align 16<br>  %add.ptr = getelementptr inbounds i8* %t1, i64 40<br>  %call = call i8* @handle_value(i8* %add.ptr, i32 3) #3<br>  %arraydecay = getelementptr inbounds [8 x i8]* %t3, i64 0, i64 0<br>  %arraydecay1 = getelementptr inbounds [16 x i8]* %t4, i64 0, i64 0<br> 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<br>  %call3 = call i8* @handle_value(i8* %add.ptr, i32 3) #3<br> <br>; Function Attrs: nounwind readonly<br>declare i8* @handle_value(i8* nocapture, i32) #1<br>; Function Attrs: nounwind<br>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<br></div></div></blockquote><div><br></div><div>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.  </div><br><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"> <br>For the above case, the second handle_value function call should be replaced with %call with cse or gvn optimization.<br> <br>Is anything I can do to optimize this case?<br> <br>thanks<br><br></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>        <a href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></body></html>