https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2021-02-23T17:38:54ZSaxonica Developer CommunitySaxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=173812021-02-23T17:38:54ZMichael Kaymike@saxonica.com
<ul><li><strong>Subject</strong> changed from <i>Range expression optimization working</i> to <i>Range expression optimization not working</i></li></ul> Saxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=173832021-02-23T22:59:28ZMichael Kaymike@saxonica.com
<ul></ul><p>I suspect the optimisation can be simplified anyway. I think <code>(A < N to M)</code> can be simplified to <code>A < M</code>.</p> Saxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=176042021-03-28T13:08:42ZMichael Kaymike@saxonica.com
<ul></ul><p>The optimisation is not kicking in because the precondition <code>manyOperandIsLiftable()</code> returns false.</p>
<p>This function only returns true if the parent expression is a context switching expression, which seems to make no sense.</p>
<p>Note: in 9.9 if the arguments are constant, we don't even get as far as considering optimisation, the expression is evaluated (slowly) during the type-checking phase. Also noted that the type checking of a the expression 1 to 10000000 in 9.9 is very slow: it appears to check that each item in the sequence is an integer!</p>
<p>The thinking behind the <code>manyOperandIsLiftable</code> test seems to be that scanning the numeric sequence to find the min and max may take longer than scanning it to find an item that is lt or gt the required value, because a min/max computation will never do an early exit. So it's justified only if the test is in a loop where the min/max computation can be reused by lifting it outside the loop. But with a range expression, the min/max computation is cheap, so this argument doesn't apply.</p> Saxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=176052021-03-28T15:36:32ZMichael Kaymike@saxonica.com
<ul></ul><p>The problem with simplifying <code>(A < N to M) </code> to <code>A < M</code> is that it gives the wrong answer in the edge case when <code>N > M</code>.</p> Saxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=176062021-03-28T18:12:33ZMichael Kaymike@saxonica.com
<ul></ul><p>I've got this working for "normal size" integer ranges, and for some constant "BigInteger" ranges. But the test case in RangeExpr-409d really isn't worth losing much sleep over: since the maximum length of a sequence is 2^31, ranges of the form M to N where M and N are both greater than 2^63 aren't going to arise very often in practice.</p> Saxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=176072021-03-28T18:25:36ZMichael Kaymike@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Applies to branch</strong> <i>10, trunk</i> added</li><li><strong>Fix Committed on Branch</strong> <i>10, trunk</i> added</li></ul> Saxon - Bug #4916: Range expression optimization not workinghttps://saxonica.plan.io/issues/4916?journal_id=178282021-04-14T15:49:59ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Fixed in Maintenance Release</strong> <i>10.5</i> added</li></ul><p>Bug fix applied to Saxon 10.5 maintenance release.</p>