On Mon, 27 Aug 2018, Jakub Jelinek wrote:

> Hi!
> 
> This patch is just a partial fix, combine.c has lots of other code that was
> written before vector modes were introduced and won't work well with them.
> 
> The patch also uses ? x : const_true_rtx rather than
> ? CONSTM1_RTX (GET_MODE (x)) : const_true_rtx
> or some new CONST_TRUE_RTX (GET_MODE (x)), so that it is backportable, that
> can be changed on the trunk incrementally.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and
> release branches?

OK.

Thanks,
Richard.

> 2018-08-27  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR rtl-optimization/87065
>       * combine.c (simplify_if_then_else): Formatting fix.
>       (if_then_else_cond): Guard MULT optimization with SCALAR_INT_MODE_P
>       check.
>       (known_cond): Don't return const_true_rtx for vector modes.  Use
>       CONST0_RTX instead of const0_rtx.  Formatting fixes.
> 
>       * gcc.target/i386/pr87065.c: New test.
> 
> --- gcc/combine.c.jj  2018-08-26 22:42:24.053753908 +0200
> +++ gcc/combine.c     2018-08-27 08:58:26.867124011 +0200
> @@ -6495,7 +6495,7 @@ simplify_if_then_else (rtx x)
>                         pc_rtx, pc_rtx, 0, 0, 0);
>        if (reg_mentioned_p (from, false_rtx))
>       false_rtx = subst (known_cond (copy_rtx (false_rtx), false_code,
> -                                from, false_val),
> +                                    from, false_val),
>                          pc_rtx, pc_rtx, 0, 0, 0);
>  
>        SUBST (XEXP (x, 1), swapped ? false_rtx : true_rtx);
> @@ -9335,6 +9335,7 @@ if_then_else_cond (rtx x, rtx *ptrue, rt
>  
>         if (COMPARISON_P (cond0)
>             && COMPARISON_P (cond1)
> +           && SCALAR_INT_MODE_P (mode)
>             && ((GET_CODE (cond0) == reversed_comparison_code (cond1, NULL)
>                  && rtx_equal_p (XEXP (cond0, 0), XEXP (cond1, 0))
>                  && rtx_equal_p (XEXP (cond0, 1), XEXP (cond1, 1)))
> @@ -9515,12 +9516,12 @@ known_cond (rtx x, enum rtx_code cond, r
>         if (COMPARISON_P (x))
>           {
>             if (comparison_dominates_p (cond, code))
> -             return const_true_rtx;
> +             return VECTOR_MODE_P (GET_MODE (x)) ? x : const_true_rtx;
>  
>             code = reversed_comparison_code (x, NULL);
>             if (code != UNKNOWN
>                 && comparison_dominates_p (cond, code))
> -             return const0_rtx;
> +             return CONST0_RTX (GET_MODE (x));
>             else
>               return x;
>           }
> @@ -9563,7 +9564,7 @@ known_cond (rtx x, enum rtx_code cond, r
>         /* We must simplify subreg here, before we lose track of the
>            original inner_mode.  */
>         new_rtx = simplify_subreg (GET_MODE (x), r,
> -                              inner_mode, SUBREG_BYTE (x));
> +                                  inner_mode, SUBREG_BYTE (x));
>         if (new_rtx)
>           return new_rtx;
>         else
> @@ -9588,7 +9589,7 @@ known_cond (rtx x, enum rtx_code cond, r
>         /* We must simplify the zero_extend here, before we lose
>            track of the original inner_mode.  */
>         new_rtx = simplify_unary_operation (ZERO_EXTEND, GET_MODE (x),
> -                                       r, inner_mode);
> +                                           r, inner_mode);
>         if (new_rtx)
>           return new_rtx;
>         else
> --- gcc/testsuite/gcc.target/i386/pr87065.c.jj        2018-08-27 
> 08:46:16.302406144 +0200
> +++ gcc/testsuite/gcc.target/i386/pr87065.c   2018-08-27 08:50:37.179025375 
> +0200
> @@ -0,0 +1,22 @@
> +/* PR rtl-optimization/87065 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -mxop -mprefer-vector-width=128" } */
> +
> +int a, c, d, e;
> +short *b;
> +
> +void
> +foo (void)
> +{
> +  short *g = b;
> +  int h = 1;
> +  unsigned i;
> +  for (; h <= 1; h++)
> +    g = (short *) &c;
> +  for (; c; c++)
> +    {
> +      for (; i <= 1; i++)
> +     ;
> +      a ^= (a > 0 <= i) + ((e += d) == 0 ?: (*g = 8));
> +    }
> +}
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to