[PATCH] D146598: [Constant] Inline ConstantInt::getSigned
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 21 19:55:57 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: reames, nikic, efriedma.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.
ConstantInt::getSigned calls ConstantInt::get with the IsSigned flag set to true.
That flag normally defaults to false.
For always signed constants the code base is not consistent about whether
it uses ConstantInt::getSigned or ConstantInt::get with IsSigned set to true.
And it's not clear how to decide which way to use.
By making getSigned inline, both ways should generate the same code in
the end.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146598
Files:
llvm/include/llvm/IR/Constants.h
llvm/lib/IR/Constants.cpp
Index: llvm/lib/IR/Constants.cpp
===================================================================
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -899,14 +899,6 @@
return get(Ty->getContext(), APInt(Ty->getBitWidth(), V, isSigned));
}
-ConstantInt *ConstantInt::getSigned(IntegerType *Ty, int64_t V) {
- return get(Ty, V, true);
-}
-
-Constant *ConstantInt::getSigned(Type *Ty, int64_t V) {
- return get(Ty, V, true);
-}
-
Constant *ConstantInt::get(Type *Ty, const APInt& V) {
ConstantInt *C = get(Ty->getContext(), V);
assert(C->getType() == Ty->getScalarType() &&
Index: llvm/include/llvm/IR/Constants.h
===================================================================
--- llvm/include/llvm/IR/Constants.h
+++ llvm/include/llvm/IR/Constants.h
@@ -111,8 +111,12 @@
/// either getSExtValue() or getZExtValue() will yield a correctly sized and
/// signed value for the type Ty.
/// Get a ConstantInt for a specific signed value.
- static ConstantInt *getSigned(IntegerType *Ty, int64_t V);
- static Constant *getSigned(Type *Ty, int64_t V);
+ static ConstantInt *getSigned(IntegerType *Ty, int64_t V) {
+ return get(Ty, V, true);
+ }
+ static Constant *getSigned(Type *Ty, int64_t V) {
+ return get(Ty, V, true);
+ }
/// Return a ConstantInt with the specified value and an implied Type. The
/// type is the integer type that corresponds to the bit width of the value.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146598.507211.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230322/0e1a5e3e/attachment.bin>
More information about the llvm-commits
mailing list