Skip to content

Conversation

felipepiovezan
Copy link

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.

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.
@felipepiovezan
Copy link
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 llvm-mc for the CAS project? I couldn't find any in test/tools/llvm-mc

@cachemeifyoucan
Copy link

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.

Copy link

@rastogishubham rastogishubham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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
```
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