[llvm] f787fe1 - [EarlyCSE] Remove unnecessary operand swap.

Michael Liao via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 23:14:15 PDT 2020


Author: Michael Liao
Date: 2020-09-11T02:14:04-04:00
New Revision: f787fe15d8e1cb63b40235e781cd7c2e130bbcd6

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

LOG: [EarlyCSE] Remove unnecessary operand swap.

- As min/max are commutative operators, there is no need to swap
  operands. That breaks the convention calculating the hash value.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/EarlyCSE.cpp
    llvm/test/CodeGen/AMDGPU/sad.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index f71a2b9e003a..e47ecb4fbb44 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -199,7 +199,6 @@ static bool matchSelectWithOptionalNotCond(Value *V, Value *&Cond, Value *&A,
   case CmpInst::ICMP_SLE:
   case CmpInst::ICMP_SGE:
     Pred = CmpInst::getInversePredicate(Pred);
-    std::swap(A, B);
     Inversed = true;
     break;
   default:

diff  --git a/llvm/test/CodeGen/AMDGPU/sad.ll b/llvm/test/CodeGen/AMDGPU/sad.ll
index 3a4a2d07772c..464b413e6558 100644
--- a/llvm/test/CodeGen/AMDGPU/sad.ll
+++ b/llvm/test/CodeGen/AMDGPU/sad.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=kaveri -earlycse-debug-hash -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
 
 ; GCN-LABEL: {{^}}v_sad_u32_pat1:
 ; GCN: v_sad_u32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}


        


More information about the llvm-commits mailing list