<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hey guys,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I'm currently investigating broadcasts from the constant pool on Sandy Bridge. I see this comment in llvm/lib/Target/X86/X86ISelLowering.cpp:</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<div> // Handle the broadcasting a single constant scalar from the constant pool</div><div> // into a vector. On Sandybridge it is still better to load a constant vector</div><div> // from the constant pool and not to broadcast it from a scalar.</div>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Would anyone be able to explain why it is better to load a vector from the constant pool rather than broadcast a scalar? </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I checked out Agner Fog's tables, but it wasn't so obvious to me...</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><pre style="white-space:pre-wrap;width:50em">vmovaps y, m256:
Uops: 1
Lat: 4
Throughput: 1
vbroadcastsd y, m64:
Uops: 2
Lat: [Not or cannot be measured]
Throughput: 1</pre><pre style="white-space:pre-wrap;width:50em;color:rgb(139,0,0)"><span style="color:rgb(0,0,0);font-family:arial;white-space:normal"><br></span></pre><pre style="white-space:pre-wrap;width:50em;color:rgb(139,0,0)">
<span style="color:rgb(0,0,0);font-family:arial;white-space:normal">Thanks in advance,</span></pre><pre style="white-space:pre-wrap;width:50em;color:rgb(139,0,0)"><span style="color:rgb(0,0,0);font-family:arial;white-space:normal">Cameron</span></pre>
</div>