On 11/09/2017 10:29 AM, Richard Biener wrote:
On Thu, Nov 9, 2017 at 4:24 PM, Andrew MacLeod <amacl...@redhat.com> wrote:
On 11/09/2017 10:16 AM, Richard Biener wrote:
On Thu, Nov 9, 2017 at 3:44 PM, Andrew MacLeod <amacl...@redhat.com>
wrote:
I'm a little confused.  In gimple I need to do a comparison between 2
values, and I create a boolean_type_node result.
I then combine it with an existing condition, but fortran is crapping out
on
me because the boolean_type I created is not
compatible with the boolean type is has already created for a different
condition:

Its not exactly this situation, but the idea is similar:

   _65 = _37 != 0;    <<-- in the IL
   _77 = _34 != 0;    <<-- Im creating this

   and something like

     (_65 != _77)

   Craps out on me because the types are incompatible.

The expression created by fortran assigned to _65 is of type:
logical(kind=4)
and mine, _77 created with boolean_type_node, is logical(kind=1)

I was under the impression that using boolean_type_node would give me the
right kind of boolean for that language, but apparently I was mistaken.

If I don't have the context of the type of _65,  how am I suppose to get
the
right boolean type for _77 when I create it? I don't want to cast it to
the
right logical kind, Id like to just get it right.   I haven't stumbled
across any hooks or other obvious thing...

I feel like I am missing something obvious...  :-P
You should already know the boolean type from the existing comparison in
the IL.
That is, you shouldn't generate conditions out of thin air, do you?  That
is,
there isn't a "single" boolean type a random hook would tell you.

Richard.
Yeah, I do actually generate them from thin air :-)   That why I said it
wasnt exactly that situation.  All I have is 2 arbitrary things that are
being compared, and then eventually I sometimes end up combining it with an
existing boolean.  I dont know in advance that I will need to combine it. I
chose boolean_type_node because I thought it was the default.
Sure - you can use boolean_type_node.  Then when combining you need
to convert to a common boolean type (choose any).  Eventually forwprop
will retroactively "fix" your (or the other) generated comparison to produce
the correct type in the first place.

I presume fortran is using SImode because it works better, or there is some
other subtle difference?
Fortran has boolean types of each size -- logical(1) to logical(16).

  so even if I wasn't eventually combining it with a
logical, and I was using the default  QImode, I would generate less than
ideal code?  Is there not a way for the optimizers to pick the preferred
type?
The preferred type depends on the context and should almost always be
boolean_type_node _unless_ the bool(s) you are working with are
loaded from / stored to memory where of course the size of the bool
matters.

OK, perfect, thats all I really need then... I'll figure out how I want to deal with it.

THanks
Andrew.

Reply via email to