[PATCH] D86843: [EarlyCSE] Equivalent SELECTs should hash equally

Bryan Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 29 19:13:10 PDT 2020


bryanpkc updated this revision to Diff 288824.
bryanpkc added a comment.

Cleaned up unused code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86843/new/

https://reviews.llvm.org/D86843

Files:
  llvm/lib/Transforms/Scalar/EarlyCSE.cpp


Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -191,6 +191,18 @@
     Pred = ICmpInst::getSwappedPredicate(Pred);
   }
 
+  // Check for inverted variants of min/max by swapping operands.
+  switch (Pred) {
+  case CmpInst::ICMP_ULE:
+  case CmpInst::ICMP_UGE:
+  case CmpInst::ICMP_SLE:
+  case CmpInst::ICMP_SGE:
+    Pred = CmpInst::getInversePredicate(Pred);
+    std::swap(A, B);
+  default:
+    break;
+  }
+
   switch (Pred) {
   case CmpInst::ICMP_UGT: Flavor = SPF_UMAX; break;
   case CmpInst::ICMP_ULT: Flavor = SPF_UMIN; break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86843.288824.patch
Type: text/x-patch
Size: 700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200830/6fd8fc05/attachment.bin>


More information about the llvm-commits mailing list