This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Request for code review - (ZEE patch : Redundant Zero extension elimination)
- From: Diego Novillo <dnovillo at google dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: Paolo Bonzini <bonzini at gnu dot org>, Ian Lance Taylor <iant at google dot com>, Richard Guenther <richard dot guenther at gmail dot com>, rth at redhat dot com, Jie Zhang <jie dot zhang at analog dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <jh at suse dot cz>, Uros Bizjak <ubizjak at gmail dot com>
- Date: Fri, 07 May 2010 12:36:39 -0400
- Subject: Re: Request for code review - (ZEE patch : Redundant Zero extension elimination)
- References: <4B4E1F14.7020508@gmail.com> <863b0cbf1001131155t74432d2ela10e2aead1a46195@mail.gmail.com> <4B551B60.3040806@analog.com> <n2q863b0cbf1004301106i2ef3146ci5ef79d2979b29373@mail.gmail.com> <o2q84fc9c001004301114g8457b1csaf062058c9ef5b22@mail.gmail.com> <mcr8w84ojss.fsf@dhcp-172-17-9-151.mtv.corp.google.com> <r2yf865508f1005010030zc7b54ea4h34056d5bd413eaf1@mail.gmail.com> <AANLkTimKF7br-0IkdpMHIteDMAcOf5uhcLjOuAL4QSab@mail.gmail.com>
On 5/3/10 18:56 , Sriraman Tallam wrote:
> +
> +shr $0x5, %edx
> +mov %edx, %edx --> Useless zero-extend.
> +
> +How to turn on ?
> +----------------
> +-fzee -O2
> +
> +*/
Please indent this whole comment two spaces.
> +
> +/* Check to see if this zero-extend matches a pattern
> + that could be eliminated. This is called via
> + for_each_rtx in function find_and_remove_ze. */
Two spaces after '.'
> + Special Cases :
> + If the expression is a constant or another zero_extend directly
> + assign it to the 64-bit register.
> +*/
Move closing comment to previous line.
> + val = INTVAL (orig_src);
> +
> + /* Zero-extending a negative 32-bit integer into 64-bits makes
> + it a positive integer. Convert the given negative integer
> + into the appropriate postive integer when zero-extended. */
s/postive/positive/
> +
> + val = 0xffffffff + val + 1;
> + gcc_assert (val > 0);
This will fail on hosts with ints different than the target. Don't you
want to do this arithmetic in the target mode here? This would not be
much of a problem for x86, but it may be in a cross compiler.
> +/* Treat if_then_else insns, where the operands of both branches
> + are registers, as copies. For instance,
> + Original :
> + (set (reg:SI a) (if_then_else (cond) (reg:SI b) (reg:SI c)))
> + Transformed :
> + (set (reg:DI a) (if_then_else (cond) (reg:DI b) (reg:DI c))) */
> +
> +static bool
> +transform_ifelse (rtx def_insn)
DEF_INSN needs documentation. I've marked a few functions that have a
similar issue. In general, you need to reference all the argument names
when describing what the function does. All the function arguments
should be capitalized.
> +/* Function to get all the immediate definitions of an instruction.
> + The reaching definitions are desired for which_reg used in
> + curr_insn. This function returns 0 if there was an error getting
> + a definition. Upon success, this function returns the number of
> + definitions. */
> +
> +static int
> +get_defs (rtx curr_insn, rtx which_reg, VEC (rtx,heap) **dest)
CURR_INSN, WHICH_REG and DEST need documentation.
> +
> + while (def_chain)
> + {
> + /* Problem getting some definition for this instruction */
> +
Finish comments with '. */'
> +
> +/* rtx function to check if this SET insn is a conditional copy insn :
> + (set (reg:SI a ) (IF_THEN_ELSE (cond) (reg:SI b) (reg:SI c)))
> + Called from is_insn_cond_copy */
> +
> +static int
> +is_this_a_cmove (rtx expr, void *data)
EXPR and DATA need documentation.
> +
> + /* Now go through the conditional copies vector and try to merge all
> + the copies in this vector.*/
Two spaces after '.'. It occurs in a few other places.
> +}
> +
> +/* Goes through the instruction stream looking for zero-extends. If the zero
> + extension instruction has atleast one def it adds it to a list of possible
> + candidates for deletion. It returns the list of candidates. */
> +static VEC (rtx,heap)*
> +find_removable_zero_extends (void)
Blank line after comment.
> +}
> +
> +static unsigned int
> +find_and_remove_ze (void)
> +{
Needs comment.
> +{
> + {
> + RTL_PASS,
> + "zee", /* name */
> + gate_handle_zee, /* gate */
> + rest_of_handle_zee, /* execute */
I never did like this RTL convention of naming passes 'rest_of_'. But
that's fine :)
>
> +fzee
> +Common Report Var(flag_zee) Init(0)
> +Eliminate redundant zero extensions on targets that supports implicit extensions.
s/supports/support/
What happens if the user specifies -fzee on a target that does not
support implicit extensions? The gating function is not checking for that.
The patch needs a ChangeLog entry. Other than that, it looks OK for commit.
Diego.