Bladeren bron

* fixed bitpacked array index calculation for llvm: the element bitsize was
only used for masking out the bits of the loaded data, not for calculating
the offset

git-svn-id: trunk@33957 -

Jonas Maebe 9 jaren geleden
bovenliggende
commit
8bc39ba7a3
1 gewijzigde bestanden met toevoegingen van 9 en 7 verwijderingen
  1. 9 7
      compiler/llvm/nllvmmem.pas

+ 9 - 7
compiler/llvm/nllvmmem.pas

@@ -237,6 +237,11 @@ implementation
       hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,ptruinttype,tarraydef(left.resultdef).lowrange-constarrayoffset,maybe_const_reg,hreg);
       constarrayoffset:=0;
 
+      { multiply index with bitsize of every element }
+      hreg2:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
+      hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_MUL,ptruinttype,l,hreg,hreg2);
+      hreg:=hreg2;
+
       { keep alignment for index }
       sref.ref.alignment:=left.resultdef.alignment;
       intloadsize:=packedbitsloadsize(l);
@@ -256,14 +261,11 @@ implementation
         sref.ref,ptruinttype,offsetreg,true));
       arraytopointerconverted:=true;
       reference_reset_base(sref.ref,basereg,0,sref.ref.alignment);
-      { calculate the bit index inside that chunk }
+      { calculate the bit index inside that chunk: mask out
+        the chunk index part }
       hreg2:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
-      { multiple index with bitsize of every element }
-      hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_MUL,ptruinttype,l,hreg,hreg2);
-      hreg:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
-      { mask out the chunk index part }
-      hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_AND,ptruinttype,(1 shl (3+alignpower))-1,hreg2,hreg);
-      sref.bitindexreg:=hreg;
+      hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_AND,ptruinttype,(1 shl (3+alignpower))-1,hreg,hreg2);
+      sref.bitindexreg:=hreg2;
       sref.startbit:=0;
       sref.bitlen:=resultdef.packedbitsize;
       if (left.location.loc=LOC_REFERENCE) then