On Mon, Apr 24, 2017 at 11:43 AM, Richard Biener
<richard.guent...@gmail.com> wrote:
> On Tue, Apr 18, 2017 at 12:43 PM, Bin Cheng <bin.ch...@arm.com> wrote:
>> Hi,
>> This patch adds three simple interfaces for tree affine which will be used in
>> cost computation later.
>>
>> Is it OK?
>
>
> +static inline tree
> +aff_combination_type (aff_tree *aff)
>
> misses a function comment.  Please do not introduce new 'static inline'
> function in headers but instead use plain 'inline'.
>
> +/* Return true if AFF is simple enough.  */
> +static inline bool
> +aff_combination_simple_p (aff_tree *aff)
> +{
>
> what is "simple"?  Based on that find a better name.
> "singleton"?  But aff_combination_const_p isn't
> simple_p (for whatever reason).
Patch updated.  The one (13th) depending on this one is updated too.

Thanks,
bin
>
> Richard.
>
>
>
>> Thanks,
>> bin
>> 2017-04-11  Bin Cheng  <bin.ch...@arm.com>
>>
>>         * tree-affine.h (aff_combination_type): New interface.
>>         (aff_combination_const_p, aff_combination_simple_p): New interfaces.
diff --git a/gcc/tree-affine.h b/gcc/tree-affine.h
index b8eb8cc..f9bdcb5 100644
--- a/gcc/tree-affine.h
+++ b/gcc/tree-affine.h
@@ -88,8 +88,15 @@ bool aff_comb_cannot_overlap_p (aff_tree *, const widest_int 
&,
 /* Debugging functions.  */
 void debug_aff (aff_tree *);
 
+/* Return AFF's type.  */
+inline tree
+aff_combination_type (aff_tree *aff)
+{
+  return aff->type;
+}
+
 /* Return true if AFF is actually ZERO.  */
-static inline bool
+inline bool
 aff_combination_zero_p (aff_tree *aff)
 {
   if (!aff)
@@ -101,4 +108,22 @@ aff_combination_zero_p (aff_tree *aff)
   return false;
 }
 
+/* Return true if AFF is actually const.  */
+inline bool
+aff_combination_const_p (aff_tree *aff)
+{
+  return (aff == NULL || aff->n == 0);
+}
+
+/* Return true iff AFF contains one singleton variable.  Users need to
+   make sure AFF points to a valid combination.  */
+inline bool
+aff_combination_singleton_var_p (aff_tree *aff)
+{
+  gcc_assert (aff != NULL);
+
+  return (aff->n == 1
+         && aff->offset == 0
+         && (aff->elts[0].coef == 1 || aff->elts[0].coef == -1));
+}
 #endif /* GCC_TREE_AFFINE_H */

Reply via email to