diff --git a/.gitattributes b/.gitattributes index ae3656329c..d046c5e955 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18348,6 +18348,7 @@ tests/webtbs/tw37228.pp svneol=native#text/plain tests/webtbs/tw37254.pp svneol=native#text/pascal tests/webtbs/tw37261.pp svneol=native#text/pascal tests/webtbs/tw37272a.pp svneol=native#text/pascal +tests/webtbs/tw37301.pp svneol=native#text/pascal tests/webtbs/tw3742.pp svneol=native#text/plain tests/webtbs/tw3751.pp svneol=native#text/plain tests/webtbs/tw3758.pp svneol=native#text/plain diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 063e72803f..7874a8db36 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -4322,14 +4322,14 @@ unit aoptx86; with taicpu(hp4).oper[OperIdx]^ do case typ of top_reg: - if reg = NR_EDX then - reg := NR_EAX; + if getsupreg(reg) = RS_EDX then + reg := newreg(R_INTREGISTER,RS_EAX,getsubreg(reg)); top_ref: begin - if ref^.base = NR_EDX then - ref^.base := NR_EAX; - if ref^.index = NR_EDX then - ref^.index := NR_EAX; + if getsupreg(reg) = RS_EDX then + ref^.base := newreg(R_INTREGISTER,RS_EAX,getsubreg(reg)); + if getsupreg(reg) = RS_EDX then + ref^.index := newreg(R_INTREGISTER,RS_EAX,getsubreg(reg)); end; else ; diff --git a/tests/webtbs/tw37301.pp b/tests/webtbs/tw37301.pp new file mode 100644 index 0000000000..43c20f939d --- /dev/null +++ b/tests/webtbs/tw37301.pp @@ -0,0 +1,13 @@ +{ %OPT=-O- -O1 } +program testbug; +{$mode objfpc}{$h+} +var + i: Integer; + b: Byte; + w: Word; +begin + i := 53; + b := 0; + w := abs(i-b); + WriteLn(w); +end.