Skip to content

Enable SelectOpt for Apple CPUs #10134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 28, 2025

Conversation

fhahn
Copy link

@fhahn fhahn commented Feb 28, 2025

rdar://142804881

davemgreen and others added 10 commits February 28, 2025 11:47
Selects that choose between two constants will be less profitable to
turn into branches, especially if the constants can be folded somehow
into the surrounding instructions. They will also be cost modelled in a
way that can make them over-optimistically converted to branches, as
neither branch will have a latency depth but the constants still need to
be materialized.

This patch disabled selectopt for selects with two constant branches. It
is currently in the target independent part, as it sounds generic, but I
could move it into AArch64 if needed.

(cherry picked from commit 1789534)
…ns (llvm#117582)

* Enables conversion of several select-like instructions within one
group
* Any number of auxiliary instructions depending on the same condition
can be in between select-like instructions
* After splitting the basic block, move select-like instructions into
the relevant basic blocks and optimise them
* Make it easier to add support shift-base select-like instructions and
also any mixture of zext/sext/not instructions

(cherry picked from commit e874c8f)
Add tests with add and sub binops with zext i1 operands.

(cherry picked from commit 231e03b)
Extra tests for llvm#115489
with different operand order. Also fixes the target triple.

(cherry picked from commit f8f238d)
Extend the support for implicit selects in the form of OR with a ZExt
operand to support ADD and SUB binops as well. They similarly can form
implicit selects which can be profitable to convert back the branches.

PR: llvm#115489
(cherry picked from commit 9a0f251)
Building on top of llvm#115489
extend support for binops with SExt operand.

PR: llvm#115879
(cherry picked from commit c1f5937)
…op to branches (llvm#119728)

Loop latches often have a loop-carried dependency, and if they have
several SelectLike instructions in one select group, it is usually
profitable to convert it to branches rather than keep selects.

(cherry picked from commit 3469996)
@fhahn fhahn requested a review from a team as a code owner February 28, 2025 11:47
@fhahn
Copy link
Author

fhahn commented Feb 28, 2025

@swift-ci please test

@fhahn fhahn merged commit 64e2812 into swiftlang:stable/20240723 Feb 28, 2025
3 checks passed
@fhahn fhahn deleted the selectopt-as-stable branch February 28, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants