Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!pasteur!agate!ucbvax!decwrl!labrea!sri-unix!garth!smryan
From: smryan@garth.UUCP (Steven Ryan)
Newsgroups: comp.arch
Subject: Vectorising conditional code.
Summary: Early exits.
Message-ID: <893@garth.UUCP>
Date: 7 Jul 88 20:11:59 GMT
References: <28200173@urbsdc> <53161@ti-csl.CSNET> <18830@cornell.UUCP> <880@garth.UUCP> <1629@kalliope.rice.edu>
Reply-To: smryan@garth.UUCP (Steven Ryan)
Organization: INTERGRAPH (APD) -- Palo Alto, CA
Lines: 22

>The loop can be ``partially vectorized'' if not all of
>the statements are part of the computation of the
>exit branch

Given something like

        for i
          a[i] := ...
          exit if p[i]
          b[i] := ...

The actual number of iterations is controlled by the predicate p[]. This means
the actual number of elements stored into a[] is determined by a subsequent
statement. I see no simple way to handle this.

Two possible solutions would be (1) buffer the assignments to a[] and b[];
stores back to arrays are deferred until the actual iteration count is
determined. (2) Float the computation of p[] to the top of loop and then
split it into a separate scalar loop. Anything between p[] and the top of
loop also has to be in the scalar loop, unless it will be bufferred as in (1).

If I were actually working on this at the moment, I would like see enough
typical cases where all the extra work is worth the effort.