aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectOptimize.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/SelectOptimize.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectOptimize.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp
index b5a8a80..a8144e4 100644
--- a/llvm/lib/CodeGen/SelectOptimize.cpp
+++ b/llvm/lib/CodeGen/SelectOptimize.cpp
@@ -515,12 +515,27 @@ void SelectOptimize::convertProfitableSIGroups(SelectGroups &ProfSIGroups) {
}
}
+static bool isSpecialSelect(SelectInst *SI) {
+ using namespace llvm::PatternMatch;
+
+ // If the select is a logical-and/logical-or then it is better treated as a
+ // and/or by the backend.
+ if (match(SI, m_CombineOr(m_LogicalAnd(m_Value(), m_Value()),
+ m_LogicalOr(m_Value(), m_Value()))))
+ return true;
+
+ return false;
+}
+
void SelectOptimize::collectSelectGroups(BasicBlock &BB,
SelectGroups &SIGroups) {
BasicBlock::iterator BBIt = BB.begin();
while (BBIt != BB.end()) {
Instruction *I = &*BBIt++;
if (SelectInst *SI = dyn_cast<SelectInst>(I)) {
+ if (isSpecialSelect(SI))
+ continue;
+
SelectGroup SIGroup;
SIGroup.push_back(SI);
while (BBIt != BB.end()) {