[llvm] 2bd4730 - [PowerPC] Fix signed overflow in decomposeMulByConstant after D88201
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 18:29:20 PDT 2020
Author: Fangrui Song
Date: 2020-10-09T18:29:12-07:00
New Revision: 2bd4730850cc0f3ab7bd0c51b18c0a220e480dc7
URL: https://github.com/llvm/llvm-project/commit/2bd4730850cc0f3ab7bd0c51b18c0a220e480dc7
DIFF: https://github.com/llvm/llvm-project/commit/2bd4730850cc0f3ab7bd0c51b18c0a220e480dc7.diff
LOG: [PowerPC] Fix signed overflow in decomposeMulByConstant after D88201
Caught by multipliers LONG_MAX (after +1) and LONG_MIN (after -1) in CodeGen/PowerPC/mul-const-i64.ll
Added:
Modified:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 57d90ef446f3..9e2dda330f54 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -16076,8 +16076,9 @@ bool PPCTargetLowering::decomposeMulByConstant(LLVMContext &Context, EVT VT,
Imm >>= Shift;
if (isInt<16>(Imm))
return false;
- if (isPowerOf2_64(Imm + 1) || isPowerOf2_64(Imm - 1) ||
- isPowerOf2_64(1 - Imm) || isPowerOf2_64(-1 - Imm))
+ uint64_t UImm = static_cast<uint64_t>(Imm);
+ if (isPowerOf2_64(UImm + 1) || isPowerOf2_64(UImm - 1) ||
+ isPowerOf2_64(1 - UImm) || isPowerOf2_64(-1 - UImm))
return true;
}
return false;
More information about the llvm-commits
mailing list