[llvm] c467946 - [IR] Improve code in isIdenticalToWhenDefined (NFC) (#151881)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 01:44:49 PDT 2025


Author: Ramkumar Ramachandra
Date: 2025-08-04T09:44:46+01:00
New Revision: c467946c3a7bf6c52aef0bdf5e51c5608a664ebf

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

LOG: [IR] Improve code in isIdenticalToWhenDefined (NFC) (#151881)

Prefer llvm::equal() over std::equal().

Added: 
    

Modified: 
    llvm/lib/IR/Instruction.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 763cc1832b794..b7cd12ac9691e 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -942,14 +942,13 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I,
 
   // We have two instructions of identical opcode and #operands.  Check to see
   // if all operands are the same.
-  if (!std::equal(op_begin(), op_end(), I->op_begin()))
+  if (!equal(operands(), I->operands()))
     return false;
 
   // WARNING: this logic must be kept in sync with EliminateDuplicatePHINodes()!
-  if (const PHINode *thisPHI = dyn_cast<PHINode>(this)) {
-    const PHINode *otherPHI = cast<PHINode>(I);
-    return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
-                      otherPHI->block_begin());
+  if (const PHINode *Phi = dyn_cast<PHINode>(this)) {
+    const PHINode *OtherPhi = cast<PHINode>(I);
+    return equal(Phi->blocks(), OtherPhi->blocks());
   }
 
   return this->hasSameSpecialState(I, /*IgnoreAlignment=*/false,


        


More information about the llvm-commits mailing list