[RFC] Type promotion pass and elimination of zext/sext

Jeff Law law@redhat.com
Thu May 19 18:17:00 GMT 2016


On 05/15/2016 06:45 PM, Kugan Vivekanandarajah wrote:
> Hi Richard,
>
> Now that stage1 is open, I would like to get the type promotion passes
> reviewed again. I have tested the patches on aarch64, x86-64, and
> ppc64le without any new execution failures. There some test-cases that
> fails for patterns. I will address them after getting feedback on the
> basic structure.
I find myself wondering if this will eliminate some of the cases where 
Kai's type casting motion was useful.  And just to be clear, that would 
be a good thing.

>
> 1. When we promote SSA as part of promote_ssa, we either promote the
> definition. Or create a copy stmt that is inserted after the stmt that
> define it. i.e, we want to promote the SSA and reflect the promotion
> on all the uses (we promote in place). We do this because, we donÂ’t
> want to change all the uses.
>
> +/* Promote definition DEF to promoted type.  If the stmt that defines def
> +   is def_stmt, make the type of def promoted type.  If the stmt is such
> +   that, result of the def_stmt cannot be of promoted type, create a new_def
> +   of the original_type and make the def_stmt assign its value to newdef.
> +   Then, create a NOP_EXPR to convert new_def to def of promoted type.
> +
> +   For example, for stmt with original_type char and promoted_type int:
> +        char _1 = mem;
> +    becomes:
> +        char _2 = mem;
> +        int _1 = (int)_2;
When does this case happen, and how is this any better than PRE or other 
elimination/code motion algorithms in improving the generated code?

I would hazard a guess that it could happen if you still needed the char 
sized used in a small number of cases, but generally wanted to promote 
most uses to int?

> +
>
> However, if the defining stmt has to be the last stmt in the basic
> block (eg, stmt that can throw), and if there is more than one normal
> edges where we use this value, we cant insert the copy in all the
> edges. Please note that the copy stmt copes the value to promoted SSA
> with the same name.
>
> Therefore I had to return false in this case for promote_ssa and fixup
> uses. I ran into this while testing ppc64le. I am sure it can happen
> in other cases.
Right.

Jeff



More information about the Gcc-patches mailing list