[fpc-devel] x86-64: MOVZX peephole optimisations

Marģers . margers.roked at inbox.lv
Fri Mar 8 15:25:48 CET 2019

> I'm a tad confused in regards to the best course
of action regarding MOVZX.  Many of the peephole
optimisations seek to change them to MOV followed
by AND (e.g. "movzbl (mem), %eax" to "mov (mem),
%al; and $0xff, %eax").  Does MOVZX have a
well-documented performance penalty in modern
processors that favours the MOV/AND combination? 
It seems odd because the combination implies a
pipeline stall, which becomes more pronounced if
the MOV instruction is reading from memory.

For intel pentium and earlier processors
combination MOV, AND was better, but now days cpu
handle MOVZX as good as MOV.  It's just question
for which cpu to optimize?

More information about the fpc-devel mailing list