[PATCH] D81349: Added checks for BinaryOperation, InsertElement, ExtractElement and changed return value in FunctionComparator

Vishal Chebrolu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 7 12:46:54 PDT 2020


vish99 created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
vish99 edited the summary of this revision.

Added special checks for BinaryOperator, InsertElement, ExtractElement since the return value is changed to return the left operation is greater if the operation opcode is not seen so far. This will not return unknown operations as equal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81349

Files:
  llvm/lib/Transforms/Utils/FunctionComparator.cpp


Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===================================================================
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -677,7 +677,23 @@
         return Res;
     }
   }
-  return 0;
+
+  if (isa<BinaryOperator>(L)) {
+    // Binary operation instructions and logical operation instructions have
+    // already been compared for opcode, number of operands, operation types,
+    // subclass optional data, operand types
+    return 0;
+  }
+  if (isa<InsertElementInst>(L) || isa<ExtractElementInst>(L)) {
+    // InsertElement and ExtractElement instructions have already been compared
+    // for opcode, number of operands, operation types, subclass optional data,
+    // operand types
+    return 0;
+  }
+
+  // Return left operation to be greater in case of instructions which are
+  // not seen.
+  return 1;
 }
 
 // Determine whether two GEP operations perform the same underlying arithmetic.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81349.269075.patch
Type: text/x-patch
Size: 1018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200607/fd124bb9/attachment.bin>


More information about the llvm-commits mailing list