<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>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.<BR>As what I know, we didn't have an attribute for this case to indict only writing to the first actual parameter.<BR>We should mark the first parameter as Mod, others as Ref and let cse work for readonly arguments.<BR> <BR>Pls kindly let me know If you know any way to mark the function to ONLY kill the first parameter for the general optimization.<BR> <BR>thanks<BR>xiaoyong<br> <BR><div><hr id="stopSpelling">Subject: Re: [LLVMdev] llvm cse optimization<br>From: nrotem@apple.com<br>Date: Fri, 11 Apr 2014 10:25:57 -0700<br>CC: llvmdev@cs.uiuc.edu<br>To: xiaoyongliu@outlook.com<br><br><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="ecxApple-interchange-newline"><blockquote><div class="ecxhmmessage" style="font: 12pt/normal Calibri; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal;"><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><div class="ecxhmmessage" style="font: 12pt/normal Calibri; text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal;"><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="ecxApple-converted-space"> </span> <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></div> </div></body>
</html>