<div dir="ltr">Thanks, I will look at it.</div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-18 1:04 GMT+02:00 Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, May 17, 2018 at 3:53 PM, Dávid Bolvanský via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> Hello,<br>
><br>
> I was thinking about a new possible simplification in InstCombine which<br>
> would transform code like this:<br>
><br>
> const char * NAME = "Prog";<br>
><br>
> void printer(char **arr, int len) {<br>
>   for (int i = 0; i < len; ++i) {<br>
>     printf("%s: %s", NAME, arr[i]);<br>
>   }<br>
> }<br>
><br>
> into<br>
><br>
> void printer(char **arr, int len) {<br>
>   for (int i = 0; i < len; ++i) {<br>
>     printf("Prog: %s", arr[i]);<br>
>   }<br>
> }<br>
><br>
> This transformation would take constant strings/integers/chars and put them<br>
> to the format string.<br>
><br>
<br>
</span>This is not a peephole optimization, therefore it doesn't belong to instcombine.<br>
If you want to try to implement something like this, I'd recommend<br>
taking a look at ConstantFolding or SCCP (and try to understand why<br>
the value doesn't get propagated).<br>
<br>
Thanks,<br>
<br>
--<br>
Davide<br>
</blockquote></div><br></div>