The existing "case AND" in this function is not sufficient for
optabs.c:avoid_expensive_constant usage, where the AND is passed in
outer_code.

        * config/rs6000/rs6000.c (rs6000_rtx_costs): Move costing for
        AND to CONST_INT case.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 32044d33977..523d029800a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21150,16 +21150,13 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int 
outer_code,
            || outer_code == MINUS)
           && (satisfies_constraint_I (x)
               || satisfies_constraint_L (x)))
-         || (outer_code == AND
-             && (satisfies_constraint_K (x)
-                 || (mode == SImode
-                     ? satisfies_constraint_L (x)
-                     : satisfies_constraint_J (x))))
-         || ((outer_code == IOR || outer_code == XOR)
+         || ((outer_code == AND || outer_code == IOR || outer_code == XOR)
              && (satisfies_constraint_K (x)
                  || (mode == SImode
                      ? satisfies_constraint_L (x)
                      : satisfies_constraint_J (x))))
+         || (outer_code == AND
+             && rs6000_is_valid_and_mask (x, mode))
          || outer_code == ASHIFT
          || outer_code == ASHIFTRT
          || outer_code == LSHIFTRT
@@ -21196,7 +21193,9 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int 
outer_code,
                    || outer_code == IOR
                    || outer_code == XOR)
                   && (INTVAL (x)
-                      & ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0))
+                      & ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0)
+              || (outer_code == AND
+                  && rs6000_is_valid_2insn_and (x, mode)))
        {
          *total = COSTS_N_INSNS (1);
          return true;
@@ -21334,26 +21333,6 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int 
outer_code,
              *total += COSTS_N_INSNS (1);
              return true;
            }
-
-         /* rotate-and-mask (no rotate), andi., andis.: 1 insn.  */
-         HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
-         if (rs6000_is_valid_and_mask (XEXP (x, 1), mode)
-             || (val & 0xffff) == val
-             || (val & 0xffff0000) == val
-             || ((val & 0xffff) == 0 && mode == SImode))
-           {
-             *total = rtx_cost (left, mode, AND, 0, speed);
-             *total += COSTS_N_INSNS (1);
-             return true;
-           }
-
-         /* 2 insns.  */
-         if (rs6000_is_valid_2insn_and (XEXP (x, 1), mode))
-           {
-             *total = rtx_cost (left, mode, AND, 0, speed);
-             *total += COSTS_N_INSNS (2);
-             return true;
-           }
        }
 
       *total = COSTS_N_INSNS (1);

Reply via email to