Issue 64241
Summary Clang MIPS: float register constraints for inline asm deviate from gcc
Labels new issue
Assignees
Reporter shravanrn
    clang and gcc seem to have different behavior of floating point constraints for inline asm. Consider this simple example

```c
// gcc compiles this but clang does not
void read_float(float* p) {
    float result = *p;
    __asm__("" ::"r"(result));
}
```
The following code compiles fine on gcc when targeting MIPS, but clang gives a compile error `couldn't allocate input reg for constraint 'r'`

Clang requires the register constraint here to be `"f"` not `"r"`. However applying an `"f"` constraint, causes gcc to fail compilation with the error `error: impossible constraint in 'asm'` while clang compiles the code fine. 

```c
// clang compiles this but gcc does not
void read_float(float* p) {
    float result = *p;
 __asm__("" ::"f"(result));
}
```

Here is a simple demo of the issue: https://godbolt.org/z/WGWxd3ejo
Test with "mips gcc 13.1.0" and "mips clang 16.0.0"

(This bug was discovered as part of the wasm2c project https://github.com/WebAssembly/wabt/issues/2266)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to