Skip to content

Commit

Permalink
[SelectOpti] Auto-disable other cmov optis when the new select-opti p…
Browse files Browse the repository at this point in the history
…ass is enabled

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D129817
  • Loading branch information
sapostolakis committed Aug 2, 2022
1 parent c2d0685 commit 995b61c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Target/X86/X86CmovConversion.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 995b61c

Please sign in to comment.