[llvm] c60a4c1 - [TypePromotion] Use Instruction* instead of Value* for a couple functions. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 19 07:18:05 PDT 2021
Author: Craig Topper
Date: 2021-08-19T07:09:38-07:00
New Revision: c60a4c1ba5980754f78765120c1ae88e1fe3cb32
URL: https://github.com/llvm/llvm-project/commit/c60a4c1ba5980754f78765120c1ae88e1fe3cb32
DIFF: https://github.com/llvm/llvm-project/commit/c60a4c1ba5980754f78765120c1ae88e1fe3cb32.diff
LOG: [TypePromotion] Use Instruction* instead of Value* for a couple functions. NFC
This matches how they are called and allows some isa/cast/dyn_cast
to be removed.
Differential Revision: https://reviews.llvm.org/D108333
Added:
Modified:
llvm/lib/CodeGen/TypePromotion.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp
index 1c9717e05eaf..a15da3b02d27 100644
--- a/llvm/lib/CodeGen/TypePromotion.cpp
+++ b/llvm/lib/CodeGen/TypePromotion.cpp
@@ -192,11 +192,8 @@ class TypePromotion : public FunctionPass {
}
-static bool GenerateSignBits(Value *V) {
- if (!isa<Instruction>(V))
- return false;
-
- unsigned Opc = cast<Instruction>(V)->getOpcode();
+static bool GenerateSignBits(Instruction *I) {
+ unsigned Opc = I->getOpcode();
return Opc == Instruction::AShr || Opc == Instruction::SDiv ||
Opc == Instruction::SRem || Opc == Instruction::SExt;
}
@@ -403,17 +400,14 @@ bool TypePromotion::shouldPromote(Value *V) {
/// Return whether we can safely mutate V's type to ExtTy without having to be
/// concerned with zero extending or truncation.
-static bool isPromotedResultSafe(Value *V) {
- if (GenerateSignBits(V))
+static bool isPromotedResultSafe(Instruction *I) {
+ if (GenerateSignBits(I))
return false;
- if (!isa<Instruction>(V))
- return true;
-
- if (!isa<OverflowingBinaryOperator>(V))
+ if (!isa<OverflowingBinaryOperator>(I))
return true;
- return cast<Instruction>(V)->hasNoUnsignedWrap();
+ return I->hasNoUnsignedWrap();
}
void IRPromoter::ReplaceAllUsersOfWith(Value *From, Value *To) {
@@ -798,7 +792,7 @@ bool TypePromotion::isLegalToPromote(Value *V) {
if (SafeToPromote.count(I))
return true;
- if (isPromotedResultSafe(V) || isSafeWrap(I)) {
+ if (isPromotedResultSafe(I) || isSafeWrap(I)) {
SafeToPromote.insert(I);
return true;
}
More information about the llvm-commits
mailing list