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


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]