[PATCH] Add if-chain to switch conversion pass.

Andrew MacLeod amacleod@redhat.com
Tue Oct 6 13:23:46 GMT 2020


On 10/6/20 9:09 AM, Martin Liška wrote:
> On 10/6/20 2:56 PM, Andrew MacLeod wrote:
>> Ah, by just using the outgoing_range class, all you are getting is 
>> static edges.  so a TRUE edge is always a [1,1] and a false edge is [0,0]
>> I provided that class so you could get the constant edges on switches.
>>
>> if you want to get actual ranges for ssa-names, you will need the 
>> ranger (which I think is going in today).  It uses those values as 
>> the starting point for winding back to calculate other dependent names.
>
> Ah, all right!
>
>>
>> Then  you will want to query the ranger for the range of index_5 on 
>> that edge..
>
> Fine! So the only tricky thing here is to select a proper SSA_NAME to 
> query right?
> In my case I need to cover situations like:
>
>   index.0_1 = (unsigned int) index_5(D);
>   _2 = index.0_1 + 4294967287;
>   if (_2 <= 114)
>
> or
>
>     _1 = aChar_8(D) == 1;
>     _2 = aChar_8(D) == 10;
>     _3 = _1 | _2;
>     if (_3 != 0)
>
> Anything Ranger can help me with?
>
> Martin
>

Well, it *does* assume you know the name of what you are looking for :-P


however, lets see.  it does know the names of things it can generate 
ranges for.     We havent gotten around to adding an API for querying 
that.  but that would be possible.

It maintains an export list of names it can calculate ranges for (as a 
bitmap). so for your 2 examples,  the export list of the first block 
contains
    _2, index.0_1, and index_5
and in the second case, it would contain
_3, _2, _1, and aChar_8

So even if you had access to the export list, you'd still have to figure 
out which one you wanted so I'm not sure that helps.  But i suppose you 
could go thru the list looking for something interesting.

I have longer term plans to expose/determine the "control names" which 
trigger the branch, and would be  '_2' in the first example and 
'aChar_8' in the second... but that facility is not built yet.



>>
>> so you will need a gimple ranger instance instead of an 
>> outgoing_range object.
>>
>> Andrew
>



More information about the Gcc-patches mailing list