Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 24
    • Merge requests 24
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #1141
Closed
Open
Created Dec 10, 2012 by Robert Bernecky@rbeDeveloper

Potential value guard optimization

Bugzilla Link 1038
Created on Dec 10, 2012 21:08
Version svn
OS Linux
Architecture PC

Extended Description

Here is a problem that has been with us since guards were introduced.
Consider this expression, used to guard against upper bound index errors
in sel() code:
 y = m - 1;
 x', p = _val_lt_val_SxS_( x, y);
 AVIS_MAX( x) = 1 + (m - 2);
CF could check for AVIS_MAX(x) == y and simplify 
this particular case. However, in general, we may have 
AVIS_MAX( x) = 1 + ( m -3), so the CF change would not
help. 
At first glance, it seems that what we want is 
something along the lines of CTZ,
where we would subtract x (or y) from both arguments of the guard. 
This, however, would cause AWLFI backtrace of index vectors from the sel()
to the WITHID_VEC to fail, so that idea is out of the picture.
A more likely approach, it seems to me, is to include an extra
argument in most/all guards, and put the computation there, as
a predicate, e.g.,:
 pred = ( x - y) < 0;
 x', p = _val_lt_val_SxS_( x, y, pred);
If CF (or some other traversal) determines that pred is true,
then the guard can be removed. If pred is false, then we raise an
index error. Otherwise, we really do not know at compile time
whether the index is valid or not, so a post-optimization path
merely removes the pred argument, and we're back to the situation
as it is today.
I stumbled onto this while looking at AWLF unit test relaxAKDnotake.sac,
compiled with -doawlf -nowlf.
sac2c -V
sac2c v1.00-beta (Haggis And Apple)
 developer rev 18038 linux-gnu_x86_64
 (Sun Dec  9 16:58:31 EST 2012 by sac)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking