This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: extend fwprop optimization


Yes, I agree with you. fold_rtx also needs to be extended because now
it only handles the case similar as follows for shift insn:
  a = b op const1
  c = a >> const2
for our motivational case, the second operand of the first insn is a
reg instead of a const. We also need to add the truncation support for
our case in simplify_binary_operation.

I will send out a more official patch about fwprop extension soon.
Then it may be easier to talk about its rationality.

Thanks,
Wei.

On Wed, Feb 27, 2013 at 1:21 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> On Wed, Feb 27, 2013 at 7:37 PM, Wei Mi wrote:
>> What do you think?
>
> I think you'll not be able to teach fold_rtx to perform the
> transformation you want it to do without having SHIFT_COUNT_TRUNCATED
> set for i386. I already tried it the other day, but GCC won't do the
> truncation without knowing the insn is really a shift insn and
> shift_truncation_mask returns something useful.
>
> Ciao!
> Steven
>
>
> Index: cse.c
> ===================================================================
> --- cse.c       (revision 196182)
> +++ cse.c       (working copy)
> @@ -3179,9 +3179,22 @@ fold_rtx (rtx x, rtx insn)
>
>         switch (GET_CODE (folded_arg))
>           {
> +         case SUBREG:
> +           /* If the SUBREG_REG comes in from an AND, and this is not a
> +              paradoxical subreg, then try to fold the SUBREG.  */
> +           if (REG_P (SUBREG_REG (folded_arg))
> +               && ! paradoxical_subreg_p (folded_arg))
> +             {
> +               rtx y = lookup_as_function (SUBREG_REG (folded_arg), AND);
> +               if (y != 0)
> +                 y = simplify_gen_binary(AND, GET_MODE (folded_arg),
> +                                         XEXP(y, 0), XEXP(y, 1));
> +               if (y != 0)
> +                 folded_arg = y;
> +             }
> +           /* ... fall through ...  */
>           case MEM:
>           case REG:
> -         case SUBREG:
>             const_arg = equiv_constant (folded_arg);
>             break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]