[LLVMdev] overflow check
Pranav Bhandarkar
pranavb at codeaurora.org
Wed Jul 13 12:09:16 PDT 2011
Hi,
I have three constants (B, C and V) and V = B + C. I want to find out if B +
C wraps around. The way I'll do it is, assuming B and C are both positive,
to check if V < B or C.
For this I need the values of B, C and V. I tried using APInt as below.
***
If (isa<Constant> (B) && isa<Constant> (C) && isa<Constant>(V)) {
ConstantInt *CV = dyn_cast<ConstantInt>(V);
ConstantInt *CB = dyn_cast<ConstantInt>(B);
ConstantInt *CC = dyn_cast<ConstantInt>(C);
if (CV && CB && CC) {
const APInt &VVal = CV->getValue();
const APInt &BVal = CB->getValue();
const APInt &CVal = CC->getValue();
******
But isn't APInt considered to represent unsigned integers ? Is there another
way of doing this ?
Thanks in advance,
Pranav
More information about the llvm-dev
mailing list