[LLVMdev] ConstantRange in PR1255

Duncan Sands baldrick at free.fr
Sun Apr 29 02:48:42 PDT 2012


Hi Stepan,

> Well... each case is represented as pair<BB, vector<Range>  >. Right?

well, you could also use vector<pair<BB, Range>>.

> We need "union" for optimal case building.

In such cases you only need union when the union will be an interval, rather
than two intervals, right?  In which case unionWith suffices.

  And we need support "difference" if we decided that some ranges or numbers in 
case will never used  (in some optimization passes it happens sometimes).

OK.

Ciao, Duncan.

>
> -Stepan
>
> 26.04.2012, 15:18, "Duncan Sands"<baldrick at free.fr>:
>> Hi Stepan,
>>
>>>   unionWith result is differs from set union, since it produces single set always
>>>   while set operations may produce two sets.
>>
>> this is true, but that's inevitable if the result is to be a single
>> ConstantRange.  You can of course define methods that returns a pair
>> of ConstantRanges and does what you want.  But why do you need these
>> methods anyway?  A "switch" is just going to be a (probably ordered)
>> list of disjoint ranges.  Where do set operations come in?
>>
>> Ciao, Duncan.
>>
>>>   E.g.:
>>>   For ranges
>>>   [1, 5) and [10,15)
>>>   unionWith produces [1,15), while set union should just keep these sets without
>>>   changing, probably with indication that sets are not intersected. Implementation
>>>   of set union is simple though.
>>>
>>>   The "symmetric difference" implementation is little bit more complex.
>>>   For two sets
>>>   [1,15) and [7,12)
>>>   symmetric difference is pair of ranges:
>>>   [1,7) and [12,15)
>>>
>>>   I propose to implement these methods in ConstantRange (I can do it).
>>>
>>>   -Stepan.




More information about the llvm-dev mailing list