diff mbox

[GCC8,11/33] New interfaces for tree affine

Message ID CAHFci2-sm+uLn7DdTWoDkshFuO=N_0xvtndn+dBdt41P_ZrTcg@mail.gmail.com
State New
Headers show

Commit Message

Bin.Cheng May 4, 2017, 3:21 p.m. UTC
On Mon, Apr 24, 2017 at 11:43 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Apr 18, 2017 at 12:43 PM, Bin Cheng <Bin.Cheng@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.cheng@arm.com>
>>
>>         * tree-affine.h (aff_combination_type): New interface.
>>         (aff_combination_const_p, aff_combination_simple_p): New interfaces.

Comments

Li, Pan2 via Gcc-patches May 8, 2017, 11:48 a.m. UTC | #1
On Thu, May 4, 2017 at 5:21 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Mon, Apr 24, 2017 at 11:43 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Tue, Apr 18, 2017 at 12:43 PM, Bin Cheng <Bin.Cheng@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.

Ok with

+inline bool
+aff_combination_singleton_var_p (aff_tree *aff)
+{
+  gcc_assert (aff != NULL);

this assert removed (aff->n will ICE anyway if NULL)

+  return (aff->n == 1
+         && aff->offset == 0
+         && (aff->elts[0].coef == 1 || aff->elts[0].coef == -1));

please adjust the comment to say "one (negated) singleton variable".

Thanks,
Richard.

> Thanks,
> bin
>>
>> Richard.
>>
>>
>>
>>> Thanks,
>>> bin
>>> 2017-04-11  Bin Cheng  <bin.cheng@arm.com>
>>>
>>>         * tree-affine.h (aff_combination_type): New interface.
>>>         (aff_combination_const_p, aff_combination_simple_p): New interfaces.
diff mbox

Patch

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 */