]> gcc.gnu.org Git - gcc.git/commitdiff
tree-vect-patterns: One small vect_recog_ctz_ffs_pattern tweak [PR109011]
authorJakub Jelinek <jakub@redhat.com>
Thu, 20 Apr 2023 17:44:27 +0000 (19:44 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 20 Apr 2023 17:44:27 +0000 (19:44 +0200)
I've noticed I've made a typo, ifn in this function this late
is always only IFN_CTZ or IFN_FFS, never IFN_CLZ.

Due to this typo, we weren't using the originally intended
.CTZ (X) = .POPCOUNT ((X - 1) & ~X)
but
.CTZ (X) = PREC - .POPCOUNT (X | -X)
instead when we want to emit __builtin_ctz*/.CTZ using .POPCOUNT.
Both compute the same value, both are defined at 0 with the
same value (PREC), both have same number of GIMPLE statements,
but I think the former ought to be preferred, because lots of targets
have andn as a single operation rather than two, and also putting
a -1 constant into a vector register is often cheaper than vector
with broadcast PREC power of two value.

2023-04-20  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109011
* tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): Use
.CTZ (X) = .POPCOUNT ((X - 1) & ~X) in preference to
.CTZ (X) = PREC - .POPCOUNT (X | -X).

gcc/tree-vect-patterns.cc

index d1b86e8b5e00cb7d233f020bccb07fd26c98ae09..a49b09539776c0056e77f99b10365d0a8747fbc5 100644 (file)
@@ -1630,7 +1630,7 @@ vect_recog_ctz_ffs_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo,
        && defined_at_zero_new
        && val == prec
        && val_new == prec)
-      || (ifnnew == IFN_POPCOUNT && ifn == IFN_CLZ))
+      || (ifnnew == IFN_POPCOUNT && ifn == IFN_CTZ))
     {
       /* .CTZ (X) = PREC - .CLZ ((X - 1) & ~X)
         .CTZ (X) = .POPCOUNT ((X - 1) & ~X).  */
This page took 0.070826 seconds and 5 git commands to generate.