Issue |
145411
|
Summary |
[clang] mips4 instructions generated when compiling for mips2
|
Labels |
clang
|
Assignees |
|
Reporter |
Sirius902
|
## The Problem
When using the `__atomic_fetch_min` and `__atomic_fetch_max` compiler builtins it is possible to generate instructions introduced in mips4 despite compiling for mips2. Following the code below compiling with `-mips2`, using `__atomic_fetch_min` generates a `movz` instruction while `__atomic_fetch_max` generates a `movn` instruction.
Here is C code that demonstrates this problem along with a [Godbolt link](https://godbolt.org/z/a7qd4dns1) demonstrating this miscompilation.
```c
int min(int* x, int y) {
return __atomic_fetch_min(x, y, __ATOMIC_SEQ_CST);
}
int max(int* x, int y) {
return __atomic_fetch_max(x, y, __ATOMIC_SEQ_CST);
}
```
## Expected Behavior
I would expect that instructions like `movz` and `movn` would not be emitted when compiling for `-mips2` since these instructions were introduced in MIPS IV, they are not present in the MIPS II standard.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs