It appears that the typical array to pointer conversion for function arguments does not work for MMA accumulator types. The user has to explicitly convert. Code: $ cat aa.c void takeacc(__vector_quad *); void passacc() { __vector_quad arr[4]; #ifdef _EXPLICIT takeacc(&arr[0]); #else takeacc(arr); #endif } Compile (success): $ gcc -mcpu=power10 -O3 aa.c -S -D_EXPLICIT && echo Success Success Compile (failure): $ gcc -mcpu=power10 -O3 aa.c -S && echo Success aa.c: In function 'passacc': aa.c:7:9: error: invalid conversion to type '* __vector_quad' 7 | takeacc(arr); | ^~~~~~~ Version: $ gcc --version gcc (GCC) 12.1.1 20220524 [releases/gcc-12 r12-8410-gf0a0aeec44] Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Confirmed. C allows to convert a pointer to data to any other pointer to data (possibly modulo alignment restrictions). What is *not* valid is accessing anything via a type not compatible with its effective type (or via a character type). So the restriction in rs6000_invalid_conversion errors for valid C programs. What was it intended to accomplish?
(In reply to Segher Boessenkool from comment #1) > So the restriction in rs6000_invalid_conversion errors for valid C programs. > What was it intended to accomplish? We do not want or allow automatic conversions between the opaque __vector_pair and __vector_quad types and other types and those are correctly disallowed there. Conversions between those types needs to go through the builtins defined for that. As for the pointer conversions tested there, I guess they came along for the ride? Nemanja, do you remember the history there? Or does LLVM allow the pointer conversions and it's just GCC that complains?
(In reply to Peter Bergner from comment #2) > We do not want or allow automatic conversions between the opaque > __vector_pair and __vector_quad types and other types and those are > correctly disallowed there. Of course, but that is not what this is about... > As for the pointer conversions tested there, I guess they came along for the > ride? Nemanja, do you remember the history there? Or does LLVM allow the > pointer conversions and it's just GCC that complains? ... this is. Possibly the restriction prevents some ICEs elsewhere, but those just need to be solved then, not hidden.
(In reply to Peter Bergner from comment #2) > (In reply to Segher Boessenkool from comment #1) > > So the restriction in rs6000_invalid_conversion errors for valid C programs. > > What was it intended to accomplish? > > We do not want or allow automatic conversions between the opaque > __vector_pair and __vector_quad types and other types and those are > correctly disallowed there. Conversions between those types needs to go > through the builtins defined for that. > > As for the pointer conversions tested there, I guess they came along for the > ride? Nemanja, do you remember the history there? Or does LLVM allow the > pointer conversions and it's just GCC that complains? Yes, the desired semantics are to disallow implicit or explicit conversions from these types to any other types. But pointer casts (presumably including reinterpret_cast in C++) should be fair game. Clang allows these conversions.
Okay, I'll handle it.
FWIW, reinterpret_cast allows exactly the same things as C casts (but with the obvious C++ extensions: member objects, member functions, C++'s concept of lvalue, that kins of thing). It is not similar to bit_cast at all.
I think we just want to remove the entire section in rs6000_invalid_conversion() that checks the XOmode/OOmode pointer conversions. Doing that fixes the ICE and fixes the PR106015 ICE too. I'm doing a bootstrap and regtest of that patch now.
*** Bug 106015 has been marked as a duplicate of this bug. ***
(In reply to Peter Bergner from comment #7) > I think we just want to remove the entire section in > rs6000_invalid_conversion() that checks the XOmode/OOmode pointer > conversions. Doing that fixes the ICE and fixes the PR106015 ICE too. I'm > doing a bootstrap and regtest of that patch now. Testing was clean, so I'll submit the patch.
The master branch has been updated by Peter Bergner <bergner@gcc.gnu.org>: https://gcc.gnu.org/g:1ae1325f24cea1698b56e4299d95446a1f7b90a2 commit r13-2239-g1ae1325f24cea1698b56e4299d95446a1f7b90a2 Author: Peter Bergner <bergner@linux.ibm.com> Date: Sat Aug 27 19:44:16 2022 -0500 rs6000: Allow conversions of MMA pointer types [PR106017] GCC incorrectly disables conversions between MMA pointer types, which are allowed with clang. The original intent was to disable conversions between MMA types and other other types, but pointer conversions should have been allowed. The fix is to just remove the MMA pointer conversion handling code altogether. gcc/ PR target/106017 * config/rs6000/rs6000.cc (rs6000_invalid_conversion): Remove handling of MMA pointer conversions. gcc/testsuite/ PR target/106017 * gcc.target/powerpc/pr106017.c: New test.
The releases/gcc-12 branch has been updated by Peter Bergner <bergner@gcc.gnu.org>: https://gcc.gnu.org/g:22ff125247ff5328ad4544aef939d491618d714d commit r12-8726-g22ff125247ff5328ad4544aef939d491618d714d Author: Peter Bergner <bergner@linux.ibm.com> Date: Sat Aug 27 19:44:16 2022 -0500 rs6000: Allow conversions of MMA pointer types [PR106017] GCC incorrectly disables conversions between MMA pointer types, which are allowed with clang. The original intent was to disable conversions between MMA types and other other types, but pointer conversions should have been allowed. The fix is to just remove the MMA pointer conversion handling code altogether. gcc/ PR target/106017 * config/rs6000/rs6000.cc (rs6000_invalid_conversion): Remove handling of MMA pointer conversions. gcc/testsuite/ PR target/106017 * gcc.target/powerpc/pr106017.c: New test. (cherry picked from commit 1ae1325f24cea1698b56e4299d95446a1f7b90a2)
The releases/gcc-11 branch has been updated by Peter Bergner <bergner@gcc.gnu.org>: https://gcc.gnu.org/g:f494a85f0bf653c3128b376c1abf821a27748c11 commit r11-10227-gf494a85f0bf653c3128b376c1abf821a27748c11 Author: Peter Bergner <bergner@linux.ibm.com> Date: Sat Aug 27 19:44:16 2022 -0500 rs6000: Allow conversions of MMA pointer types [PR106017] GCC incorrectly disables conversions between MMA pointer types, which are allowed with clang. The original intent was to disable conversions between MMA types and other other types, but pointer conversions should have been allowed. The fix is to just remove the MMA pointer conversion handling code altogether. gcc/ PR target/106017 * config/rs6000/rs6000.c (rs6000_invalid_conversion): Remove handling of MMA pointer conversions. gcc/testsuite/ PR target/106017 * gcc.target/powerpc/pr106017.c: New test. (cherry picked from commit 1ae1325f24cea1698b56e4299d95446a1f7b90a2)
The releases/gcc-10 branch has been updated by Peter Bergner <bergner@gcc.gnu.org>: https://gcc.gnu.org/g:3927bd9f9150576f2905c8930732c419f1850fca commit r10-10966-g3927bd9f9150576f2905c8930732c419f1850fca Author: Peter Bergner <bergner@linux.ibm.com> Date: Sat Aug 27 19:44:16 2022 -0500 rs6000: Allow conversions of MMA pointer types [PR106017] GCC incorrectly disables conversions between MMA pointer types, which are allowed with clang. The original intent was to disable conversions between MMA types and other other types, but pointer conversions should have been allowed. The fix is to just remove the MMA pointer conversion handling code altogether. gcc/ PR target/106017 * config/rs6000/rs6000.c (rs6000_invalid_conversion): Remove handling of MMA pointer conversions. gcc/testsuite/ PR target/106017 * gcc.target/powerpc/pr106017.c: New test. (cherry picked from commit 1ae1325f24cea1698b56e4299d95446a1f7b90a2)
Fixed everywhere.