[llvm-mc][CAS] Add sanity check for CAS backend flags#5028
Closed
felipepiovezan wants to merge 1 commit intoswiftlang:experimental/cas/mainfrom
Closed
[llvm-mc][CAS] Add sanity check for CAS backend flags#5028felipepiovezan wants to merge 1 commit intoswiftlang:experimental/cas/mainfrom
felipepiovezan wants to merge 1 commit intoswiftlang:experimental/cas/mainfrom
Conversation
The `--cas-backend` flag is only compatible with `--filetype=obj`, however no error is produced if a different filetype is specified, and the `--cas-backend` flag is silently ignored. This patch emits an error in these cases, to prevent incorrect usage of the tool.
Author
|
I'm proposing this patch to prevent accidental misuse by newcomers to the CAS project. @cachemeifyoucan do we have tests for the flags added to |
|
It is also currently only compatible with MachO output. If you want to add a diagnostic to prevent misuse, it would be good to add that as well. |
swift-ci
pushed a commit
that referenced
this pull request
Jul 1, 2025
Combine sequences such as:
```llvm
%pn1 = phi [init1, %BB1], [%op1, %BB2]
%pn2 = phi [init2, %BB1], [%op2, %BB2]
%op1 = binop %pn1, constant1
%op2 = binop %pn2, constant2
%rdx = binop %op1, %op2
```
Into:
```llvm
%phi_combined = phi [init_combined, %BB1], [%op_combined, %BB2]
%rdx_combined = binop %phi_combined, constant_combined
```
This allows us to simplify interleaved reductions, for example as
introduced by the loop vectorizer.
The anecdotal example for this is the loop below:
```c
float foo() {
float q = 1.f;
for (int i = 0; i < 1000; ++i)
q *= .99f;
return q;
}
```
Which currently gets lowered explicitly such as (on AArch64,
interleaved by four):
```gas
.LBB0_1:
fmul v0.4s, v0.4s, v1.4s
fmul v2.4s, v2.4s, v1.4s
fmul v3.4s, v3.4s, v1.4s
fmul v4.4s, v4.4s, v1.4s
subs w8, w8, #32
b.ne .LBB0_1
```
But with this patch lowers trivially:
```gas
foo:
mov w8, #5028
movk w8, llvm#14389, lsl #16
fmov s0, w8
ret
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--cas-backendflag is only compatible with--filetype=obj,however no error is produced if a different filetype is specified, and
the
--cas-backendflag is silently ignored. This patch emits an errorin these cases, to prevent incorrect usage of the tool.