Selaa lähdekoodia

* set register size correctly for popcnt(<byte>), resolves #37400
(cherry picked from commit ed158f1e52f826525aa2f6ad5005cee9cfab0ad3)

# Conflicts:
# .gitattributes

florian 5 vuotta sitten
vanhempi
commit
055283f9cb
2 muutettua tiedostoa jossa 18 lisäystä ja 0 poistoa
  1. 6 0
      compiler/x86/nx86inl.pas
  2. 12 0
      tests/webtbs/tw37400.pp

+ 6 - 0
compiler/x86/nx86inl.pas

@@ -1011,6 +1011,12 @@ implementation
           emit_reg_reg(A_POPCNT,TCGSize2OpSize[opsize],left.location.register,location.register)
         else
           emit_ref_reg(A_POPCNT,TCGSize2OpSize[opsize],left.location.reference,location.register);
+
+        if resultdef.size=1 then
+          begin
+            location.size:=OS_8;
+            location.register:=cg.makeregsize(current_asmdata.CurrAsmList,location.register,location.size);
+          end;
       end;
 
 

+ 12 - 0
tests/webtbs/tw37400.pp

@@ -0,0 +1,12 @@
+{ %cpu=i386,x86_64 }
+{ %opt=-Cpcoreavx2 }
+function popc ( a, b: byte):byte;
+var z,v: byte;
+begin  
+     z:=a+b;
+     v:=popcnt(z); //-- this line
+     popc:=v;
+end;
+
+begin
+end.