<HTML>
<div><style> BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }</style>In that case, I would argue that it should optimise for more modern processors - that is, favour MOVZX, especially as the first few Pentium processors were released in the 90s. If backwards-compatibility is more of a concern, well, if compiling for x86-64, when it's certain that the processor was released no earlier than the early 2000s (because, for x86_64-win64, SSE2 has to be present) and hence MOVZX is efficient, while i386 and i8086 can favour MOV/AND.<br>
<br>
Nevertheless, there is code in parts of the compiler that check for things like "if current_settings.cputype<cpu_Pentium2 then", so setting a preference for MOV/AND is still an option.<br>
</div><div><br>
</div><div>Once the work with my x86_64 optimizer overhaul is accepted or rejected, I can make some conversions if approved.<br>
<br>
Gareth aka. Kit<br>
</div><br>
<br>
<br>
<span style="font-weight: bold;">On Fri 08/03/19 14:25 , "Marģers ." margers.roked@inbox.lv sent:<br>
</span><blockquote style="BORDER-LEFT: #F5F5F5 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"><span style="color: rgb(102, 102, 102);">> I'm a tad confused in regards to the best course
</span><br>
of action regarding MOVZX. Many of the peephole
<br>
optimisations seek to change them to MOV followed
<br>
by AND (e.g. "movzbl (mem), %eax" to "mov (mem),
<br>
%al; and $0xff, %eax"). Does MOVZX have a
<br>
well-documented performance penalty in modern
<br>
processors that favours the MOV/AND combination?
<br>
It seems odd because the combination implies a
<br>
pipeline stall, which becomes more pronounced if
<br>
the MOV instruction is reading from memory.
<br>
<br>
For intel pentium and earlier processors
<br>
combination MOV, AND was better, but now days cpu
<br>
handle MOVZX as good as MOV. It's just question
<br>
for which cpu to optimize?
<br>
<br>
<br>
<br>
</blockquote></HTML>