<div dir="ltr">Hello,<div><br></div><div>I was thinking about a new possible simplification in InstCombine which would transform code like this:</div><div><br></div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254)"><div><span style="color:rgb(0,0,255)">const</span> <span style="color:rgb(0,0,255)">char</span> * NAME = <span style="color:rgb(163,21,21)">"Prog"</span>;</div><br><div><span style="color:rgb(0,0,255)">void</span> printer(<span style="color:rgb(0,0,255)">char</span> **arr, <span style="color:rgb(0,0,255)">int</span> len) {</div><div>    <span style="color:rgb(0,0,255)">  for</span> (<span style="color:rgb(0,0,255)">int</span> i = <span style="color:rgb(9,136,90)">0</span>; i < len; ++i) {</div><div>    printf(<span style="color:rgb(163,21,21)">"%s: %s"</span>, NAME, arr[i]);</div><div>  }</div><div>}</div><div><br></div><div>into</div><div><br><div><span style="color:rgb(0,0,255)">void</span> printer(<span style="color:rgb(0,0,255)">char</span> **arr, <span style="color:rgb(0,0,255)">int</span> len) {</div><div>    <span style="color:rgb(0,0,255)">  for</span> (<span style="color:rgb(0,0,255)">int</span> i = <span style="color:rgb(9,136,90)">0</span>; i < len; ++i) {</div><div>    printf(<span style="color:rgb(163,21,21)">"</span><span style="color:rgb(163,21,21)">Prog:</span><span style="color:rgb(163,21,21)"> %s"</span>, arr[i]);</div><div>  }</div><div>}<br></div></div><div><br></div><div>This transformation would take constant strings/integers/chars and put them to the format string.</div><div><br></div><div>In the example I used "printf" but it could be applied also for fprintf and sprintf.</div><div><br></div><div>Do you consider this as good to be implemented? Or not worth to do at all?</div><div><br></div><div>I implemented it some time ago personally just for fun to try it. I would reimplement it and send a patch to LLVM if any interest.</div><div><br></div><div>Ideas? Complains? Suggestions? </div><div><br></div><div>Thanks</div></div></div></div>