diff options
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index ff61f1a..8ee1f19 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -6013,7 +6013,9 @@ bool CodeGenPrepare::tryToPromoteExts( // cut this search path, because it means we degrade the code quality. // With exactly 2, the transformation is neutral, because we will merge // one extension but leave one. However, we optimistically keep going, - // because the new extension may be removed too. + // because the new extension may be removed too. Also avoid replacing a + // single free extension with multiple extensions, as this increases the + // number of IR instructions while not providing any savings. long long TotalCreatedInstsCost = CreatedInstsCost + NewCreatedInstsCost; // FIXME: It would be possible to propagate a negative value instead of // conservatively ceiling it to 0. @@ -6021,7 +6023,8 @@ bool CodeGenPrepare::tryToPromoteExts( std::max((long long)0, (TotalCreatedInstsCost - ExtCost)); if (!StressExtLdPromotion && (TotalCreatedInstsCost > 1 || - !isPromotedInstructionLegal(*TLI, *DL, PromotedVal))) { + !isPromotedInstructionLegal(*TLI, *DL, PromotedVal) || + (ExtCost == 0 && NewExts.size() > 1))) { // This promotion is not profitable, rollback to the previous state, and // save the current extension in ProfitablyMovedExts as the latest // speculative promotion turned out to be unprofitable. |