When doing arithmetic/indexing on pointers to one-byte types, don't generate code to multiply by one.

This could already be optimized out by the peephole optimizer, but it's bad enough code that it really shouldn't be generated even when not using that optimization.
This commit is contained in:
Stephen Heumann
2017-10-29 20:25:43 -05:00
parent 8d31481182
commit e780043007

View File

@@ -2176,29 +2176,37 @@ case tp of
cgByte,cgUByte,cgWord,cgUWord: begin cgByte,cgUByte,cgWord,cgUWord: begin
if (size = long(size).lsw) and (op = pc_adl) if (size = long(size).lsw) and (op = pc_adl)
and smallMemoryModel and (tp in [cgUByte,cgUWord]) then begin and smallMemoryModel and (tp in [cgUByte,cgUWord]) then begin
if size <> 1 then begin
Gen1t(pc_ldc, long(size).lsw, cgWord); Gen1t(pc_ldc, long(size).lsw, cgWord);
Gen0(pc_umi); Gen0(pc_umi);
end; {if}
Gen0t(pc_ixa, cgUWord); Gen0t(pc_ixa, cgUWord);
end {if} end {if}
else if smallMemoryModel and (size = long(size).lsw) then begin else if smallMemoryModel and (size = long(size).lsw) then begin
if size <> 1 then begin
Gen1t(pc_ldc, long(size).lsw, cgWord); Gen1t(pc_ldc, long(size).lsw, cgWord);
Gen0(pc_mpi); Gen0(pc_mpi);
end; {if}
Gen2(pc_cnv, ord(tp), ord(cgLong)); Gen2(pc_cnv, ord(tp), ord(cgLong));
Gen0(op); Gen0(op);
end {else if} end {else if}
else begin else begin
Gen2(pc_cnv, ord(tp), ord(cgLong)); Gen2(pc_cnv, ord(tp), ord(cgLong));
if size <> 1 then begin
GenLdcLong(size); GenLdcLong(size);
Gen0(pc_mpl); Gen0(pc_mpl);
end; {if}
Gen0(op); Gen0(op);
end; end;
end; end;
cgLong,cgULong: begin cgLong,cgULong: begin
if size <> 1 then begin
GenLdcLong(size); GenLdcLong(size);
if tp = cgLong then if tp = cgLong then
Gen0(pc_mpl) Gen0(pc_mpl)
else else
Gen0(pc_uml); Gen0(pc_uml);
end; {if}
Gen0(op); Gen0(op);
end; end;
otherwise: otherwise: