This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GSoC] writing test-case


On Mon, May 19, 2014 at 5:51 PM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Thu, 15 May 2014, Richard Biener wrote:
>
>> To me predicate (and capture without expression or predicate)
>> differs from expression in that predicate is clearly a leaf of the
>> expression tree while we have to recurse into expression operands.
>>
>> Now, if we want to support applying predicates to the midst of an
>> expression, like
>>
>> (plus predicate(minus @0 @1)
>>         @2)
>> (...)
>>
>> then this would no longer be true.  At the moment you'd write
>>
>> (plus (minus@3 @0 @1)
>>         @2)
>>   if (predicate (@3))
>> (...)
>>
>> which makes it clearer IMHO (with the decision tree building
>> you'd apply the predicates after matching the expression tree
>> anyway I suppose, so code generation would be equivalent).
>
> Syntaxwise I had this idea for adding generic predicates to expressions:
>
> (plus (minus @0 @1):predicate
>       @2)
> (...)

So you'd write

 (plus @0 :integer_zerop)

instead of

 (plus @0 integer_zerop)

?

> If prefix or suffix doesn't matter much, but using a different syntax
> to separate expression from predicate seems to make things clearer.
> Optionally adding things like and/or for predicates might also make sense:
>
> (plus (minus @0 @1):positive_p(@0) || positive_p(@1)
>       @2)
> (...)

negation whould be more useful I guess.  You open up a can of
worms with ordering though:

(plus (minus @0 @1) @2:operand_equal_p (@1, @2, 0))

which might be declared invalid or is equivalent to

(plus (minus @0 @1) @2):operand_equal_p (@1, @2, 0)

?

Note that your predicate placement doesn't match placement of
captures for non-innermost expressions.  capturing the outer
plus would be

(plus@3 (minus @0 @1) @2)

not

(plus (minus @0 @1) @2)@3

so maybe apply predicates there as well:

(plus:operand_equal_p (@1, @2, 0) (minus @0 @1)  @2)

But I still think that doing all predicates within a if-expr makes
the pattern less convoluted.

Enabling/disabling a whole set of patterns with a common condition
might still be a worthwhile addition.

Richard.

>
> Ciao,
> Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]