[LLVMdev] signed/unsigned integers ?
Nick Lewycky
nicholas at mxc.ca
Thu Mar 31 22:08:59 PDT 2011
me22 wrote:
> On Wed, Mar 30, 2011 at 03:19, Julien Henry<Julien.Henry at imag.fr> wrote:
>>
>> Actually, I'm working on a static analyzer that computes invariants at
>> each basicBlock: "In basicBlock B, what is the set of possible
>> assignments for each live values ?"
>> and I obtains results such as "In B, we have 0<= x<= 42"
>>
>
> Well, you have to find that from the comparisons that control the
> branches to the blocks, so you determine signedness from the
> signedness of the comparison instructions. (And get to have the fun
> of figuring out the right thing to do when the instructions mix
> signedness.)
It's not that hard :) There's already two ways to get a ConstantRange
out of an ICmpInst; ICmpInst::makeConstantRange(predicate, apint) (eg.,
produce the range representing everything signed-less than 100) and
ConstantRange::makeICmpRegion(predicate, constant-range) (eg., produce
the range of all values that *could satisty* the predicate (signed
less-than, etc.) any of the values in a range).
Then you union them (if either way leads to block) or intersect them (if
the conditions are and'd together).
Nick
>
> ~ Scott
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list