<div dir="ltr"><div><div>I went back to this problem after looking at some other things. Turning on debugging I noticed that the register coalescer is trying to do the "right thing" and merge vreg0 (the previous load of the constant) with the first parameter of the call (%rdi), which is exactly what gcc does in this case - eliminating a second constant load, but its refusing to do the merge:<br>
<br></div>Here's the debug output for that part of the compilation:<br><br>********** SIMPLE REGISTER COALESCING **********<br>********** Function: caller<br>********** JOINING INTERVALS ***********<br>entry:<br>64B     %RDI<def> = COPY %vreg0; GR64:%vreg0<br>
        Considering merging %vreg0 with %RDI<br>        Can only merge into reserved registers.<br>Remat: %RDI<def> = MOV64ri 12345123400<br>Shrink: [32r,64r:0)  0@32r<br>Shrunk: [32r,48r:0)  0@32r<br>Trying to inflate 0 regs.<br>
********** INTERVALS **********<br>%vreg0 = [32r,48r:0)  0@32r<br>RegMasks: 80r<br><br></div>Jakob, what does "can only merge into reserved registers" mean in this instance. I don't see any reason for it not to do the merge.<br>
<br><br><div><div><div><div><div style id="__af745f8f43-e961-4b88-8424-80b67790c964__"></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 5, 2013 at 11:19 AM, Jakob Stoklund Olesen <span dir="ltr"><<a href="mailto:stoklund@2pi.dk" target="_blank">stoklund@2pi.dk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Aug 5, 2013, at 8:34 AM, Maurice Marks <<a href="mailto:maurice.marks@gmail.com">maurice.marks@gmail.com</a>> wrote:<br>
<br>
> Are you sure that's it? I commented that block out, rebuilt llvm 3.3,  and it still duplicates the constant.<br>
> My concern is that long constant loads increase code size and if they can be avoided by better targeting it would be a win. My project's application of llvm tends to use a lot of long constants so this can be a significant optimization.<br>

> I'll do some more debugging now that you have pointed me in the right direction.<br>
<br>
</div>It is also possible that the coalescer is duplicating the instruction like Rafael suggested. It will do that if it can't eliminate a copy.<br>
<span class="HOEnZb"><font color="#888888"><br>
/jakob<br>
<br>
</font></span></blockquote></div><br></div>