Hello,
I have two APInt variables, which are got by ConstantSDNode::getAPIntValue().
Is there a simple way to know if their multiplication overflows?
For example, if both APInt vars contain a int32_t,
APInt a, b;
Then I think
if (a.getMinSignedBits() + b.getMinSignedBits() > 32)
a*b must exceeds int32_t <=> overflow happens;
Is my way OK?
Ben Shi
Hello,
I have two APInt variables, which are got by ConstantSDNode::getAPIntValue().
Is there a simple way to know if their multiplication overflows?
There's APInt::smul_ov(const APInt &RHS, bool &Overflow)
For example, if both APInt vars contain a int32_t,
APInt a, b;
Then I think
if (a.getMinSignedBits() + b.getMinSignedBits() > 32)
a*b must exceeds int32_t <=> overflow happens;
Is my way OK?
Ben Shi
Roman