Hi Will,

On Thu, Oct 12, 2017 at 03:03:12PM -0500, Will Schmidt wrote:
>       * config/rs6000/rs6000.c: (rs6000_gimple_fold_builtin) Add support for
>       folding of vector compares.  (builtin_function_type) Add compare
>       builtins to the list of functions having unsigned arguments.
>       * config/rs6000/vsx.md:  Add vcmpne{b,h,w} instructions.

        * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for
        folding of vector compares.
        (builtin_function_type): Add compare builtins to the list of functions
        having unsigned arguments.
        * config/rs6000/vsx.md (vcmpneb_spec, vcmpneh_spec, vcmpnew_spec): New.

> +    case ALTIVEC_BUILTIN_VCMPEQUB:
> +    case ALTIVEC_BUILTIN_VCMPEQUH:
> +    case ALTIVEC_BUILTIN_VCMPEQUW:
> +    case P8V_BUILTIN_VCMPEQUD:
> +      {
> +     arg0 = gimple_call_arg (stmt, 0);
> +     arg1 = gimple_call_arg (stmt, 1);
> +     lhs = gimple_call_lhs (stmt);
> +     gimple *g = gimple_build_assign (lhs, EQ_EXPR, arg0, arg1);
> +     gimple_set_location (g, gimple_location (stmt));
> +     gsi_replace (gsi, g, true);
> +     return true;
> +      }

I wonder how much it helps to factor out the bodies here...  So this could
be like:

+    case ALTIVEC_BUILTIN_VCMPEQUB:
+    case ALTIVEC_BUILTIN_VCMPEQUH:
+    case ALTIVEC_BUILTIN_VCMPEQUW:
+    case P8V_BUILTIN_VCMPEQUD:
+      gsi_replace_call_2arg (gsi, EQ_EXPR, stmt);
+      return true;

with

static void
gsi_replace_call_2arg (gimple_stmt_iterator *gsi, tree_code code, gimple *stmt)
{
  tree arg0 = gimple_call_arg (stmt, 0);
  tree arg1 = gimple_call_arg (stmt, 1);
  tree lhs = gimple_call_lhs (stmt);
  gimple *g = gimple_build_assign (lhs, code, arg0, arg1);
  gimple_set_location (g, gimple_location (stmt));
  gsi_replace (gsi, g, true);
}

(But maybe too many other cases need special code?  And it could use a
better name).

>      default:
>       if (TARGET_DEBUG_BUILTIN)
>          fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n",
>                   fn_code, fn_name1, fn_name2);
>        break;
>      }
> -
>    return false;
>  }

Please drop this part.  Whitespace is good ;-)

> @@ -18112,10 +18188,27 @@ builtin_function_type (machine_mode mode_ret, 
> machine_mode mode_arg0,

> +      h.uns_p[1]=1;
> +      h.uns_p[2]=1;

+      h.uns_p[1] = 1;
+      h.uns_p[2] = 1;


> diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md

> +;; Vector Compare Not Equal Byte (specified/not+eq:)
> +(define_insn "vcmpneb_spec"
> +  [(set (match_operand:V16QI 0 "altivec_register_operand" "=v")
> +      (not:V16QI
> +        (eq:V16QI (match_operand:V16QI 1 "altivec_register_operand" "v")
> +                  (match_operand:V16QI 2 "altivec_register_operand" "v"))))]
> +  "TARGET_P9_VECTOR"
> +  "vcmpneb %0,%1,%2"
> +  [(set_attr "type" "vecsimple")]
> +)

+  [(set_attr "type" "vecsimple")])

What does "_spec" mean?  That it is not an unspec?  :-)

If a name is not (expected to be) used directly, it should start with *.

Do we still need the unspec version?


Segher

Reply via email to