diff options
author | Nikita Popov <npopov@redhat.com> | 2023-09-15 11:31:28 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-09-15 13:50:08 +0200 |
commit | ab6667f844e2a5e072bf9710b09fdb7b5ebd8cc5 (patch) | |
tree | bf5f6a10ae8b63da32cbb2877ad4eca88fff78e0 /llvm/lib/IR/ConstantRange.cpp | |
parent | 73371faf05887fbe84916456b7c200b07978e7b5 (diff) | |
download | llvm-ab6667f844e2a5e072bf9710b09fdb7b5ebd8cc5.zip llvm-ab6667f844e2a5e072bf9710b09fdb7b5ebd8cc5.tar.gz llvm-ab6667f844e2a5e072bf9710b09fdb7b5ebd8cc5.tar.bz2 |
[ConstantRange] Optimize smul nowrap with constant (NFC)
Don't call makeExactMulNSWRegion() twice with the same value.
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index d22d56e..3d71b20 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -326,6 +326,10 @@ ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, if (Unsigned) return makeExactMulNUWRegion(Other.getUnsignedMax()); + // Avoid one makeExactMulNSWRegion() call for the common case of constants. + if (const APInt *C = Other.getSingleElement()) + return makeExactMulNSWRegion(*C); + return makeExactMulNSWRegion(Other.getSignedMin()) .intersectWith(makeExactMulNSWRegion(Other.getSignedMax())); |