[llvm-commits] [LLVM, SwitchInst, case ranges] Auxiliary patch #1

Chris Lattner clattner at apple.com
Thu Jan 5 12:58:14 PST 2012


On Jan 5, 2012, at 11:17 AM, Stepan Dyatkovskiy wrote:

>> If we were only interested in solving #1, we'd want to have a [start,end] range value for each edge out of a switch.  However, this isn't enough to solve #2...
> I think solving #2 solves #1 too. After analysing code I saw that it is more profitable to use case-ranges internal representation.
> 
>> Given a structure like this, I revise my stance and think that it would be easiest to represent this with a ConstantArray, and maybe even represent the ranges as ConstantVectors or something.
>> 
>> What do you think?
> I think that ConstantArray is fine. But what the difference for our case between ConstantArray and ConstantVector? Low level implementation? IMHO the main point is that it is inherited from Constant and will stored in LLVMContext. How it will stored in operands collection?

My half-baked thought was that we could store 1, 4...7, 12  as [1, <4, 7>, 12], just to distinguish ranges from pairs of scalar values.

> The last one is not a principle. Here we just should hide getOperand and getSuccessor methods (it is low level methods isn't it?).  We should replace code fragments like
> CaseValue = SI->getOperand(SomeIndex); // We use User methods keeping SwitchInst format in mind.
> CaseSuccessor = SI->getSuccessor(SomeIndex2); // We use TerminatorInst methods keeping what each successor means in mind.
> with
> CaseValue = SI->getCaseValue(SomeCaseValueIndex);
> Successor = SI->getCaseSuccessor(SomeSuccessorIndex);

I may not be understanding what you mean, but I think that getting rid of getOperand() (hiding it in SwitchInst) makes sense.  getSuccessor() still needs to exist though.


-Chris



More information about the llvm-commits mailing list