]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Commonise some folding code
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 20 Oct 2022 09:37:35 +0000 (10:37 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 20 Oct 2022 09:37:35 +0000 (10:37 +0100)
Add an aarch64_sve::gimple_folder helper for folding calls
to integer constants.  SME will make more use of this.

gcc/
* config/aarch64/aarch64-sve-builtins.h
(gimple_folder::fold_to_cstu): New member function.
* config/aarch64/aarch64-sve-builtins.cc
(gimple_folder::fold_to_cstu): Define.
* config/aarch64/aarch64-sve-builtins-base.cc
(svcnt_bhwd_impl::fold): Use it.

gcc/config/aarch64/aarch64-sve-builtins-base.cc
gcc/config/aarch64/aarch64-sve-builtins.cc
gcc/config/aarch64/aarch64-sve-builtins.h

index 141f44d4d948d4477500a720fbb29a959e666211..23b4d42822ad437d5f101796ffd1ca9141c75aab 100644 (file)
@@ -517,9 +517,7 @@ public:
   gimple *
   fold (gimple_folder &f) const override
   {
-    tree count = build_int_cstu (TREE_TYPE (f.lhs),
-                                GET_MODE_NUNITS (m_ref_mode));
-    return gimple_build_assign (f.lhs, count);
+    return f.fold_to_cstu (GET_MODE_NUNITS (m_ref_mode));
   }
 
   rtx
@@ -553,10 +551,7 @@ public:
     unsigned int elements_per_vq = 128 / GET_MODE_UNIT_BITSIZE (m_ref_mode);
     HOST_WIDE_INT value = aarch64_fold_sve_cnt_pat (pattern, elements_per_vq);
     if (value >= 0)
-      {
-       tree count = build_int_cstu (TREE_TYPE (f.lhs), value);
-       return gimple_build_assign (f.lhs, count);
-      }
+      return f.fold_to_cstu (value);
 
     return NULL;
   }
index 63b1358c13813b6e3ddc9bd0ea9b7b7ff74bcb75..37228f6389aa3594b3a865278f9e5724084d40f5 100644 (file)
@@ -2615,6 +2615,13 @@ gimple_folder::redirect_call (const function_instance &instance)
   return call;
 }
 
+/* Fold the call to constant VAL.  */
+gimple *
+gimple_folder::fold_to_cstu (poly_uint64 val)
+{
+  return gimple_build_assign (lhs, build_int_cstu (TREE_TYPE (lhs), val));
+}
+
 /* Fold the call to a PTRUE, taking the element size from type suffix 0.  */
 gimple *
 gimple_folder::fold_to_ptrue ()
index 63d1db776f7030ea650e095c92b766a20091db07..0d130b871d0976b96ecfb3acee2edf7ab3b26b2e 100644 (file)
@@ -500,6 +500,7 @@ public:
   tree load_store_cookie (tree);
 
   gimple *redirect_call (const function_instance &);
+  gimple *fold_to_cstu (poly_uint64);
   gimple *fold_to_pfalse ();
   gimple *fold_to_ptrue ();
   gimple *fold_to_vl_pred (unsigned int);