Issue 243549
Summary [PowerPC] "Unknown mismatch!" assertion with a long double register variable in an FPR used as an "f" operand
Labels new issue
Assignees
Reporter mu-mu-mu
    On powerpc64le, a `long double` local register variable in `fr0` used as an `"+f"` operand hits the "Unknown mismatch!" assertion in `getCopyToParts`.

### Reproducer

```c
long double f(long double v)
{
    register long double x __asm__("fr0") = v;
    __asm__ volatile("" : "+f"(x));
    return x;
}
```

```console
$ clang --target=powerpc64le-linux-gnu -c test.c
```

### Actual behavior

Trunk c0005dfe81f with assertions:

```console
$ clang --version
clang version 24.0.0git
Build config: +assertions
```

```console
$ clang --target=powerpc64le-linux-gnu -c test.c
clang: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:579: void getCopyToParts(...): Assertion `(PartVT.isInteger() || PartVT == MVT::x86mmx) && ValueVT.isInteger() && "Unknown mismatch!"' failed.
...
4.	Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@f'
...
llvm::SelectionDAGBuilder::visitInlineAsm(llvm::CallBase const&, llvm::BasicBlock const*)
```

test-faa7a5.c

```c
# 1 "<built-in>"
# 1 "test.c"
long double f(long double v)
{
    register long double x __asm__("fr0") = v;
    __asm__ volatile("" : "+f"(x));
    return x;
}
```

test-faa7a5.sh

```sh
# Crash reproducer for clang version 24.0.0git
# Driver args: "--target=powerpc64le-linux-gnu" "-c" "test.c" "-o" "/dev/null"
# Original command: "/opt/clang-trunk/bin/clang-24" "-cc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "test.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "ppc64le" "-mfloat-abi" "hard" "-target-abi" "elfv2" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/w" "-fcoverage-compilation-dir=/w" "-resource-dir" "/opt/clang-trunk/lib/clang/24" "-internal-isystem" "/opt/clang-trunk/lib/clang/24/include/ppc_wrappers" "-internal-isystem" "/opt/clang-trunk/lib/clang/24/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc-cross/powerpc64le-linux-gnu/16/../../../../powerpc64le-linux-gnu/include" "-internal-externc-isystem" "/usr/include/powerpc64le-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-faddrsig" "-fdwarf2-cfi-asm" "-o" "/dev/null" "-x" "c" "test.c"
 "/opt/clang-trunk/bin/clang-24" "-cc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "test.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "ppc64le" "-mfloat-abi" "hard" "-target-abi" "elfv2" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/w" "-fcoverage-compilation-dir=/w" "-ferror-limit" "19" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-faddrsig" "-fdwarf2-cfi-asm" "-x" "c" "test-faa7a5.c"
```

Without assertions (godbolt clang trunk), -O2 fails with "fatal error: error in backend: do not know how to expand this operator's operand!".


### Expected behavior

Clang should either correctly handle the long double, or reject it.

clang (assertions trunk): https://godbolt.org/z/qjPz7Ws9M

clang (trunk, -O2): https://godbolt.org/z/s717f9Wrc

Found by automated testing.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to