[llvm] 870e6b6 - [InstCombine] use dyn_cast instead of isa+cast; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 10:53:29 PST 2023


Author: Sanjay Patel
Date: 2023-03-06T13:49:47-05:00
New Revision: 870e6b6e6527bf8b9f56f1310e30c2d785585d2e

URL: https://github.com/llvm/llvm-project/commit/870e6b6e6527bf8b9f56f1310e30c2d785585d2e
DIFF: https://github.com/llvm/llvm-project/commit/870e6b6e6527bf8b9f56f1310e30c2d785585d2e.diff

LOG: [InstCombine] use dyn_cast instead of isa+cast; NFC

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index d5584b77aa826..2565abcffd71e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -1389,11 +1389,10 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
 
   // If all PHI operands are the same operation, pull them through the PHI,
   // reducing code size.
-  if (isa<Instruction>(PN.getIncomingValue(0)) &&
-      isa<Instruction>(PN.getIncomingValue(1)) &&
-      cast<Instruction>(PN.getIncomingValue(0))->getOpcode() ==
-          cast<Instruction>(PN.getIncomingValue(1))->getOpcode() &&
-      PN.getIncomingValue(0)->hasOneUser())
+  auto *Inst0 = dyn_cast<Instruction>(PN.getIncomingValue(0));
+  auto *Inst1 = dyn_cast<Instruction>(PN.getIncomingValue(1));
+  if (Inst0 && Inst1 && Inst0->getOpcode() == Inst1->getOpcode() &&
+      Inst0->hasOneUser())
     if (Instruction *Result = foldPHIArgOpIntoPHI(PN))
       return Result;
 


        


More information about the llvm-commits mailing list