Index: lib/Transforms/Scalar/LoopUnswitch.cpp =================================================================== --- lib/Transforms/Scalar/LoopUnswitch.cpp +++ lib/Transforms/Scalar/LoopUnswitch.cpp @@ -463,6 +463,11 @@ return true; } + // Do not do non-trivial unswitch while optimizing for size. + // FIXME: Use Function::optForSize(). + if (OptimizeForSize || F->hasFnAttribute(Attribute::OptimizeForSize)) + return false; + // Loop over all of the basic blocks in the loop. If we find an interior // block that is branching on a loop-invariant condition, we can unswitch this // loop. @@ -598,11 +603,6 @@ return false; } - // Do not do non-trivial unswitch while optimizing for size. - // FIXME: Use Function::optForSize(). - if (OptimizeForSize || F->hasFnAttribute(Attribute::OptimizeForSize)) - return false; - UnswitchNontrivialCondition(LoopCond, Val, currentLoop, TI); return true; }