[fpc-devel] Case block optimisation

J. Gareth Moreton gareth at moreton-family.com
Thu Dec 27 19:31:35 CET 2018


 Hi everyone.
 This is just a follow-up on https://bugs.freepascal.org/view.php?id=34762,
since the issue has been marked as resolved now.

 The apparent regression doesn't seem to exist.  Both the trunk (before it
was updated) and the patch produce a linear list for the test in question -
e.g.:

 .section
.text.n_p$casebranchtest$_$tsparsedataequal2_$__$$_dotestiteration$longint,"x"
     .balign 16,0x90
 .globl   
P$CASEBRANCHTEST$_$TSPARSEDATAEQUAL2_$__$$_DOTESTITERATION$LONGINT
 P$CASEBRANCHTEST$_$TSPARSEDATAEQUAL2_$__$$_DOTESTITERATION$LONGINT:
 .Lc188:
     andl    $1023,%edx
     movswl    %dx,%eax
     subl    $512,%eax
     movswl    %dx,%edx
     cmpl    $-509,%eax
     je    .Lj501
     cmpl    $-353,%eax
     je    .Lj535
     cmpl    $-329,%eax
     je    .Lj502
     ....

 The only difference are the label numbers.  You are right though Florian
- in this instance, a jump table should not be used because the domain is
massive at 1,024, while only 39 of those values go to branches.  If a jump
table were used, it would be 4 KB in size, and 985 of the 1,024 entries
would point to the else block.  I'm not sure why you got such a huge time
difference.

 I'd like to keep these tests around though because those "Domain is 1,024"
tests are rather extreme cases that could be fun to find optimisations for
(if any exist).

 Gareth aka. Kit
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20181227/fb531c76/attachment.html>


More information about the fpc-devel mailing list