[LLVMdev] arithmetic with SCEVs, SCEVConsts, ConstInts, and APInts

Preston Briggs preston.briggs at gmail.com
Mon Apr 16 18:26:15 PDT 2012


Hi,

Pondering the code for StrongSIV and trying to write my own, I find I have
many questions.
In this code, for example,

* if (isa<SCEVConstant>(delta) && isa<SCEVConstant>(srcCoeff)) {
   const SCEVConstant *constDelta = cast<SCEVConstant>(delta);
   const SCEVConstant *constCoeff = cast<SCEVConstant>(srcCoeff);
   APInt distance, remainder;
   APInt::sdivrem(constDelta->getValue()->getValue(),
                  constCoeff->getValue()->getValue(),
                  distance, remainder);

*

Generally, this makes sense. But reading the documentation for APInt, it
sounds like I must somehow ensure that the representations ofconstDelta and
constCoeff are the same length. Are they going to be automatically, or do I
need to do something to check?

How do we set the lengths of distance and remainder? Or are they set by the
sdivrem operations?

If I want to divide distance by 2, how do I create an APInt with the value
of 2 and the correct length?
I've seen you create an SCEV with value 2. Should I do that each time?

I'm working on writing out Banerjee and Wolfe's exact SIV test and the
hardest part seems to be specifying the type of all the various numbers.
I'm manipulating many constants (0, 1, and various SCEVConstants) and doing
arithmetic with them. I assume it's better (quicker, smaller) to use APInts
for everything.

Any general advice?

Thanks,
Preston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120416/c782ddd9/attachment.html>


More information about the llvm-dev mailing list