[llvm-dev] Is there a simple way to check APInt multiplication overflow? (original) (raw)
Roman Lebedev via llvm-dev llvm-dev at lists.llvm.org
Sat Jul 11 04:53:51 PDT 2020
- Previous message: [llvm-dev] Is there a simple way to check APInt multiplication overflow?
- Next message: [llvm-dev] Branch is not optimized because of right shift
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Jul 11, 2020 at 2:49 PM Ben Shi via llvm-dev <llvm-dev at lists.llvm.org> wrote:
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 int32t, APInt a, b; Then I think
if (a.getMinSignedBits() + b.getMinSignedBits() > 32) a*b must exceeds int32t <=> overflow happens; Is my way OK? Ben Shi Roman
LLVM Developers mailing list llvm-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
- Previous message: [llvm-dev] Is there a simple way to check APInt multiplication overflow?
- Next message: [llvm-dev] Branch is not optimized because of right shift
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]