[llvm] 995b61c - [SelectOpti] Auto-disable other cmov optis when the new select-opti pass is enabled

Sotiris Apostolakis via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 1 17:27:15 PDT 2022


Author: Sotiris Apostolakis
Date: 2022-08-02T00:19:59Z
New Revision: 995b61cdacaa944dd3021b3dd23a91da90136e07

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

LOG: [SelectOpti] Auto-disable other cmov optis when the new select-opti pass is enabled

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D129817

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp
    llvm/lib/Target/X86/X86CmovConversion.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index b8f6fc9bbcde9..d5d08f04d4cd8 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6741,6 +6741,10 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
   if (DisableSelectToBranch)
     return false;
 
+  // If the SelectOptimize pass is enabled, selects have already been optimized.
+  if (!getCGPassBuilderOption().DisableSelectOptimize)
+    return false;
+
   // Find all consecutive select instructions that share the same condition.
   SmallVector<SelectInst *, 2> ASI;
   ASI.push_back(SI);

diff  --git a/llvm/lib/Target/X86/X86CmovConversion.cpp b/llvm/lib/Target/X86/X86CmovConversion.cpp
index f32891552a820..8016960681966 100644
--- a/llvm/lib/Target/X86/X86CmovConversion.cpp
+++ b/llvm/lib/Target/X86/X86CmovConversion.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/CGPassBuilderOption.h"
 #include <algorithm>
 #include <cassert>
 #include <iterator>
@@ -167,6 +168,10 @@ bool X86CmovConverterPass::runOnMachineFunction(MachineFunction &MF) {
   if (!EnableCmovConverter)
     return false;
 
+  // If the SelectOptimize pass is enabled, cmovs have already been optimized.
+  if (!getCGPassBuilderOption().DisableSelectOptimize)
+    return false;
+
   LLVM_DEBUG(dbgs() << "********** " << getPassName() << " : " << MF.getName()
                     << "**********\n");
 


        


More information about the llvm-commits mailing list