31 Commits

Author SHA1 Message Date
dewen
3b82336188
Revert "[PM] Execute IndVarSimplifyPass precede RessociatePass" (#71617)
Reverts llvm/llvm-project#71054
2023-11-08 09:22:55 +08:00
dewen
e4d27d7f32
[PM] Execute IndVarSimplifyPass precede RessociatePass (#71054)
ReassociatePass may clear nsw/nuw flags of some instructions, which may
have side effects on optimizations in IndVarSimplifyPass.
2023-11-08 09:21:17 +08:00
Amara Emerson
1a2e77cf9e Revert "Revert "Inlining: Run the legacy AlwaysInliner before the regular inliner.""
This reverts commit 86bfeb906e3a95ae428f3e97d78d3d22a7c839f3.

This is a long time coming re-application that was originally reverted due to
regressions, unrelated to the actual inlining change. These regressions have since
been fixed due to another long-in-the-making change of a66051c6 landing.

Original commit message for reference:
---
    We have several situations where it's beneficial for code size to ensure that every
    call to always-inline functions are inlined before normal inlining decisions are
    made. While the normal inliner runs in a "MandatoryOnly" mode to try to do this,
    it only does it on a per-SCC basis, rather than the whole module. Ensuring that
    all mandatory inlinings are done before any heuristic based decisions are made
    just makes sense.

    Despite being referred to the "legacy" AlwaysInliner pass, it's already necessary
    for -O0 because the CGSCC inliner is too expensive in compile time to run at -O0.

    This also fixes an exponential compile time blow up in
    https://github.com/llvm/llvm-project/issues/59126

    Differential Revision: https://reviews.llvm.org/D143624
---
2023-10-28 23:21:11 -07:00
Florian Hahn
e6a1657fa3
[ConstraintElim] Add A < B if A is an increasing phi for A != B.
This patch adds additional logic to add additional facts for A != B, if
A is a monotonically increasing induction phi. The motivating use case
for this is removing checks when using iterators with hardened libc++,
e.g. https://godbolt.org/z/zhKEP37vG.

The patch pulls in SCEV to detect AddRecs. If possible, the patch adds
the following facts for a AddRec phi PN with StartValue as incoming
value from the loo preheader and B being an upper bound for PN from a
condition in the loop header.

 * (ICMP_UGE, PN, StartValue)
 * (ICMP_ULT, PN, B) [if (ICMP_ULE, StartValue, B)]

The patch also adds an optional precondition to FactOrCheck (the new
DoesHold field) , which can be used to only add a fact if the
precondition holds at the point the fact is added to the constraint
system.

Depends on D151799.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D152730
2023-09-27 11:00:28 +01:00
Florian Hahn
04f9a8a7d6
[ConstraintElim] Move just before loop simplification pipeline.
Adjust the pipeline slightly to move ConstraintElim just before the loop
simplification pipeline. This increases the number of cases where SCEV
should can preserved in the future.

This also enables slightly more opportunities, by benefiting from
earlier CFG simplifications, which allow more conditions to be added.

Reviewed By: nikic, antoniofrighetto

Differential Revision: https://reviews.llvm.org/D158843
2023-09-22 14:31:08 +01:00
Dhruv Chawla
3e992d81af
[InferAlignment] Enable InferAlignment pass by default
This gives an improvement of 0.6%:
https://llvm-compile-time-tracker.com/compare.php?from=7d35fe6d08e2b9b786e1c8454cd2391463832167&to=0456c8e8a42be06b62ad4c3e3cf34b21f2633d1e&stat=instructions:u

Differential Revision: https://reviews.llvm.org/D158600
2023-09-20 12:08:52 +05:30
khei4
7f3610ac69 Reapply "Revert "[MemCpyOpt] implement multi BB stack-move optimization"
This reverts commit efe8aa2e618122e8050af10cc5d6ad83f24ef557.

Differential Revision: https://reviews.llvm.org/D155406
2023-09-14 19:42:36 +09:00
Vitaly Buka
efe8aa2e61 Revert "Reapply "Revert "[MemCpyOpt] implement multi BB stack-move optimization""
Suspecting incorrect lifetime markers.

This reverts commit 3a1409f93da32bf626f76257e0aac71716f2f67e.
2023-09-07 11:14:19 -07:00
khei4
3a1409f93d Reapply "Revert "[MemCpyOpt] implement multi BB stack-move optimization"
This reverts commit e0f9cc71cb6f4eb2e1566177e05425c497759dc6.
Differential Revision: https://reviews.llvm.org/D155406
2023-08-29 19:40:29 +09:00
Vitaly Buka
e0f9cc71cb Revert "Reapply "Revert "[MemCpyOpt] implement multi BB stack-move optimization"""
Breaks multiple bots. e.g. https://lab.llvm.org/buildbot/#/builders/19/builds/18856

This reverts commit ac0072602c9d01fc031a2d0acb418f7191480ef0.
2023-08-26 19:24:50 -07:00
khei4
ac0072602c Reapply "Revert "[MemCpyOpt] implement multi BB stack-move optimization""
This reverts commit 3bb32c61b2f1f5d14dd056dd198dc898dce5a44e.

Use InsertionPt for DT to handle non-memory access dominators

Differential Revision: https://reviews.llvm.org/D155406
2023-08-27 06:50:19 +09:00
khei4
3bb32c61b2 Revert "[MemCpyOpt] implement multi BB stack-move optimization"
This reverts commit ef867d2ea10e8246be20c608160e07a54eb2ed14.

crash on sanitizer build https://lab.llvm.org/buildbot/#/builders/70/builds/42861/steps/10/logs/stdio
2023-08-24 22:56:39 +09:00
khei4
ef867d2ea1 [MemCpyOpt] implement multi BB stack-move optimization
Differential Revision: https://reviews.llvm.org/D155406
2023-08-24 22:19:01 +09:00
Alexandros Lamprineas
475ddca56e Reland "[FuncSpec] Replace LoopInfo with BlockFrequencyInfo"
Using AvgLoopIters on any loop is too imprecise making the cost model
favor users inside loop nests regardless of the actual tripcount.

Differential Revision: https://reviews.llvm.org/D150375
2023-06-08 17:44:47 +01:00
Nikita Popov
96a14f388b Revert "[FuncSpec] Replace LoopInfo with BlockFrequencyInfo"
As reported on https://reviews.llvm.org/D150375#4367861 and
following, this change causes PDT invalidation issues. Revert
it and dependent commits.

This reverts commit 0524534d5220da5ecb2cd424a46520184d2be366.
This reverts commit ced90d1ff64a89a13479a37a3b17a411a3259f9f.
This reverts commit 9f992cc9350a7f7072a6dbf018ea07142ea7a7ed.
This reverts commit 1b1232047e83b69561fd64b9547cb0a0d374473a.
2023-05-30 14:49:03 +02:00
Arthur Eubanks
13e3d4aa5a [Pipeline] Don't run EarlyFPM in LTO post link
EarlyFPM cleans up the output of the frontend. This isn't necessary in post link pipelines as the pre link pipeline already ran this.

~0.4% savings in ThinLTO builds:
https://llvm-compile-time-tracker.com/compare.php?from=8a5d4eb775c644d8683f24817d44c510d2b853b7&to=3580252a2162eadca0da99f1eeaa112f74a0353d&stat=instructions:u

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145403
2023-05-25 09:32:54 -07:00
Alexandros Lamprineas
1b1232047e [FuncSpec] Replace LoopInfo with BlockFrequencyInfo.
Using AvgLoopIters on any loop is too imprecise making the cost model
favor users inside loop nests regardless of the actual tripcount.

Differential Revision: https://reviews.llvm.org/D150375
2023-05-22 17:49:52 +01:00
Shoaib Meenai
141be5c062 Revert "Reland [Pipeline] Don't limit ArgumentPromotion to -O3"
This reverts commit 6f29d1adf29820daae9ea7a01ae2588b67735b9e.

https://reviews.llvm.org/D149768 is causing size regressions for -Oz
with FullLTO, and I'm reverting that one while investigating. This
commit depends on that one, so it needs to be reverted as well.
2023-05-05 14:26:57 -07:00
Arthur Eubanks
6f29d1adf2 Reland [Pipeline] Don't limit ArgumentPromotion to -O3
This is a cheap pass so there's no need to limit to -O3.
This removes some differences between various pipelines.

Code size regressions should be addressed with
https://reviews.llvm.org/D149768.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D148269
2023-05-03 13:17:30 -07:00
Arthur Eubanks
09d27bdb86 Revert "[Pipeline] Don't limit ArgumentPromotion to -O3"
This reverts commit 5b386b864c7619897c51a1da97d78f1cf6f3eff6.

Causes noticeable size increases under -Oz.
2023-05-03 08:57:47 -07:00
serge-sans-paille
afa13ba18d
Reapply Move "auto-init" instructions to the dominator of their users
Original patch (50b2a113db197a97f60ad2aace8b7382dc9b8c31) ignored the
fact that -ftrivial-auto-var-init could affect function parameters with
the sret attribute.
Just do not move instruction that don't affect alloca.
Also add missing test case for volatile instruction.

Differential Revision: https://reviews.llvm.org/D148507
2023-04-24 18:10:10 +02:00
Nikita Popov
e7e4c76320 [Pipelines] Don't run ForceFunctionAttrs post-link
This is effectively a debugging pass to adjust function attributes.
I don't think it makes sense to run it in the post-link pipeline.

Differential Revision: https://reviews.llvm.org/D148904
2023-04-24 09:58:06 +02:00
Nikita Popov
22a408ae51 [Pipelines] Don't explicitly require ORE
LICM does not use ORE from the pass manager, it constructs its
own instance. As such, explicitly requiring the analysis in the
pipeline is unnecessary.
2023-04-21 13:22:04 +02:00
Arthur Eubanks
5b386b864c [Pipeline] Don't limit ArgumentPromotion to -O3
This is a cheap pass so there's no need to limit to -O3.
This removes some differences between various pipelines.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D148269
2023-04-14 10:00:41 -07:00
Arthur Eubanks
4bf9ca5eec [Pipeline] Remove Annotation2Metadata pass in post-link pipelines
The pre-link pipeline already ran the pass and it only needs to be run once.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D145978
2023-04-12 20:34:09 -07:00
Hans Wennborg
a6d9730f40 Revert "Move "auto-init" instructions to the dominator of their users"
This could also move initialization of sret args, causing actually
initialized parts of such return values to be uninitialized. See
discussion on the code review.

> As a result of -ftrivial-auto-var-init, clang generates instructions to
> set alloca'd memory to a given pattern, right after the allocation site.
> In some cases, this (somehow costly) operation could be delayed, leading
> to conditional execution in some cases.
>
> This is not an uncommon situation: it happens ~500 times on the cPython
> code base, and much more on the LLVM codebase. The benefit greatly
> varies on the execution path, but it should not regress on performance.
>
> This is a recommit of cca01008cc31a891d0ec70aff2201b25d05d8f1b with
> MemorySSA update fixes.
>
> Differential Revision: https://reviews.llvm.org/D137707

This reverts commit 50b2a113db197a97f60ad2aace8b7382dc9b8c31
and follow-up commit ad9ad3735c4821ff4651fab7537a75b8f0bb60f8.
2023-04-12 13:37:21 +02:00
Dávid Bolvanský
05a2f4290e [AggressiveInstCombine] Enable also for -O2
Next step after https://reviews.llvm.org/D113179

Recently a set of patches by @anton-afanasyev improved many cases (better and cleaner vectorized code) thanks to improvements to AIC's TruncInstCombine (IC cannot handle it) motivated by real examples in bug reports. There was a discussion that -O2 could benefit from AIC as well, but discussion then stalled, so I would like restart it, with new numbers from LLVM compile time tracker.

As -O2 pipeline is not tracked by LLVM compile time tracker, I disabled AIC for -O3 to get an idea how expensive is it. Without AIC, I observed that geomean was cca -0.10%. Given that it seems like AIC is quite cheap, heavily tested by -O3 pipeline, I am proposing to enable it also with -O2 and similar to improve quality to vectorized code.

https://llvm-compile-time-tracker.com/compare.php?from=a1df5abef5f27646c809c7b85cf6170eb68f7735&to=e1ba6068f58c6ca862b920b8750faccb42a5843c&stat=instructions:u

Differential Revision: https://reviews.llvm.org/D147604
Reviewed-By: nikic
2023-04-05 16:51:21 +02:00
serge-sans-paille
50b2a113db
Move "auto-init" instructions to the dominator of their users
As a result of -ftrivial-auto-var-init, clang generates instructions to
set alloca'd memory to a given pattern, right after the allocation site.
In some cases, this (somehow costly) operation could be delayed, leading
to conditional execution in some cases.

This is not an uncommon situation: it happens ~500 times on the cPython
code base, and much more on the LLVM codebase. The benefit greatly
varies on the execution path, but it should not regress on performance.

This is a recommit of cca01008cc31a891d0ec70aff2201b25d05d8f1b with
MemorySSA update fixes.

Differential Revision: https://reviews.llvm.org/D137707
2023-04-04 07:30:03 +02:00
serge-sans-paille
11ae47dfc6
Revert "Move "auto-init" instructions to the dominator of their users"
This reverts commit cca01008cc31a891d0ec70aff2201b25d05d8f1b.

This change breaks memory ssa checks, see https://lab.llvm.org/buildbot#builders/109/builds/60970
2023-04-03 15:46:18 +02:00
serge-sans-paille
cca01008cc
Move "auto-init" instructions to the dominator of their users
As a result of -ftrivial-auto-var-init, clang generates instructions to
set alloca'd memory to a given pattern, right after the allocation site.
In some cases, this (somehow costly) operation could be delayed, leading
to conditional execution in some cases.

This is not an uncommon situation: it happens ~500 times on the cPython
code base, and much more on the LLVM codebase. The benefit greatly
varies on the execution path, but it should not regress on performance.

Differential Revision: https://reviews.llvm.org/D137707
2023-04-03 15:27:27 +02:00
Arthur Eubanks
511ddfe265 [test] Split up new-pm-thinlto-defaults.ll into prelink and postlink pipelines
They're becoming different enough that it's getting annoying to figure out how allocate check prefixes.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D146486
2023-03-21 09:18:09 -07:00