llvm / llvm/llvm-project

[X86][clang] contradictory x86-64-v4 frontend and backend behavior

Open
#215,139 2 comments 0 reactions 0 assignees View on GitHub
backend:X86 clang:driver question
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

1.
```c++
void foo(long *__restrict a, long *__restrict b){
for(int i=0;i<8;i++){
a[i]=b[i];
}
}
```
-O3 -march=x86-64-v4
```asm
foo(long*, long*):
vmovups ymm0, ymmword ptr [rsi]
vmovups ymm1, ymmword ptr [rsi + 32]
vmovups ymmword ptr [rdi + 32], ymm1
vmovups ymmword ptr [rdi], ymm0
vzeroupper
ret

```
-O3 -march=x86-64-v4 -mtune=generic
```asm
foo(long*, long*):
vmovups zmm0, zmmword ptr [rsi]
vmovups zmmword ptr [rdi], zmm0
vzeroupper
ret

```
Doesn't x86-64-vX just mean tuning is generic? Why does explicitly -mtune=generic changes prefer-vector-width?

2.
run clang -mtune=help

```
Available CPUs for this target:

x86-64
x86-64-v2
x86-64-v3
x86-64-v4
```

run clang -mtune=generic

```
error: unknown target CPU 'x86-64-v4'
```
What does this mean?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two clang compilations and the `-mtune=help` and `-mtune=generic` commands from the issue. Trace how `-march=x86-64-v4`, `-mtune=generic`, vector width selection, and the listed target CPUs are interpreted; done means explaining or correcting the contradictory code-generation and diagnostic behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.