[patch] Cleanup and improvement of if-conversion for vectorization

Richard Guenther rguenther@suse.de
Tue May 25 12:05:00 GMT 2010


On Mon, 24 May 2010, Sebastian Pop wrote:

> Hi,
> 
> The attached patch-set cleans the code of the current if-conversion
> pass, separates the analysis of the basic block predicates from the
> transformation, and improves the if-conversion by transforming loops
> containing conditions with memory references.  Conditional writes to
> memory are handled as non conditional writes by reading and writing
> back the same value, like this:
> 
> +/* Predicate each write to memory in LOOP.
> +
> +   Replace a statement "A[i] = foo" with "A[i] = cond ? foo : A[i]"
> +   with the condition COND determined from the ->aux field of the
> +   basic block containing the statement.  */
> 
> With this patch set, I am XFAIL-ing vect-ifcvt-18.c that I am
> considering unsafe for the if-conversion as currently implemented in
> trunk.  I am XFAIL-ing it until I get a patch that checks that a
> statically allocated data reference cannot trap in a loop accessed
> niter times.  vect-ifcvt-18.c looks like the testcase of
> http://gcc.gnu.org/PR43423
> 
> __attribute__ ((noinline)) void
> foo (int mid, int n)
> {
>   int i;
> 
>   for (i = 0; i < n; i++)
>     if (i < mid)
>       A[i] = A[i] + B[i];
>     else
>       A[i] = A[i] + C[i];
> }
> 
> After if-conversion the accesses to B and C would be executed for
> every iteration, and without proving that B and C have "n" elements,
> the if-converted code could trap.
> 
> The patch-set passes test and bootstrap with BOOT_CFLAGS="-g -O3".
> Ok for trunk?

Patch #2 is broken.  There are never memory references in COND_EXPRs
and they never have VOPs.

Patch #3 is obvious.

Patch #4 is ok.

Patch #5 is ok.

Patch #6 is not ok (why's it needed?)

Patch #7 is not ok (the original code looks ok, though you might
want to use create_tmp_reg instead).  Please explain why the
patch is needed.

Patch #8 is ok (though it does look expensive).

Patch #9 is ok.

Patch #10 is ok.

Patch #11.  predicate_bbs needs an
overall comment on what you are doing (and using trees is ugly,
you basically un-CSE the predicates as well).
+  mark_sym_for_renaming (gimple_vop (cfun));
should not be necessary.  Why do you need it?
+  /* Now, all statements are if-converted: combine all the basic
+     blocks into one huge basic block.  */
   combine_blocks (loop);
I thought now combine_blocks does the if-conversion.

Patch #12.  Why is loop->header not special-case?  In is_predicated
use ()s to properly vertically align the predicates.

Patch #13.  See my initial comment.  With the large number of patches
it is hard to follow the series at this point - I'm defering detailed
review of the rest until the previous changes are sorted out / committed.

Thanks,
Richard.



More information about the Gcc-patches mailing list