Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -3060,14 +3060,15 @@ else SelectKind = TargetLowering::ScalarValSelect; - // Do we have efficient codegen support for this kind of 'selects' ? - if (TLI->isSelectSupported(SelectKind)) { - // We have efficient codegen support for the select instruction. - // Check if it is profitable to keep this 'select'. - if (!TLI->isPredictableSelectExpensive() || - !isFormingBranchFromSelectProfitable(SI)) - return false; - } + // When the target architecture does not support select, or the select + // is expensive, or heuristics suggest branches are more profitable then + // turn the select into a branch + // FIXME: isFormingBranchSelectProfitable() should be target specific also. + bool ConvertToBranch = !TLI->isSelectSupported(SelectKind) || + TLI->isPredictableSelectExpensive() || + isFormingBranchFromSelectProfitable; + if (!ConvertToBranch) + return false; ModifiedDT = true;