[PATCH] D108333: [TypePromotion] Use Instruction* instead of Value* for a couple functions. NFC

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 18 15:05:27 PDT 2021


craig.topper created this revision.
craig.topper added a reviewer: samparker.
Herald added a subscriber: hiraditya.
craig.topper requested review of this revision.
Herald added a project: LLVM.

This matches how they are called and allows some isa/cast/dyn_cast
to be removed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108333

Files:
  llvm/lib/CodeGen/TypePromotion.cpp


Index: llvm/lib/CodeGen/TypePromotion.cpp
===================================================================
--- llvm/lib/CodeGen/TypePromotion.cpp
+++ llvm/lib/CodeGen/TypePromotion.cpp
@@ -192,11 +192,8 @@
 
 }
 
-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 @@
 
 /// 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 @@
   if (SafeToPromote.count(I))
    return true;
 
-  if (isPromotedResultSafe(V) || isSafeWrap(I)) {
+  if (isPromotedResultSafe(I) || isSafeWrap(I)) {
     SafeToPromote.insert(I);
     return true;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108333.367334.patch
Type: text/x-patch
Size: 1443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210818/d630bb55/attachment.bin>


More information about the llvm-commits mailing list