[Bug target/106017] [PowerPC] No array-to-pointer conversion for MMA accumulator

2022-06-17 Thread nemanja.i.ibm at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106017

--- Comment #4 from Nemanja Ivanovic  ---
(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.

[Bug c/106017] New: [PowerPC] No array-to-pointer conversion for MMA accumulator

2022-06-17 Thread nemanja.i.ibm at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106017

Bug ID: 106017
   Summary: [PowerPC] No array-to-pointer conversion for MMA
accumulator
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nemanja.i.ibm at gmail dot com
  Target Milestone: ---

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.

[Bug c/106016] New: [PowerPC] crash with attempt to initialize array of MMA accumulators

2022-06-17 Thread nemanja.i.ibm at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106016

Bug ID: 106016
   Summary: [PowerPC] crash with attempt to initialize array of
MMA accumulators
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nemanja.i.ibm at gmail dot com
  Target Milestone: ---

Code:
$ cat aa.c 
void array_crash(__vector_quad *a, __vector_quad *b) {
  __vector_quad arr[2] = {*a, *b}; // Should not crash
}

Compile:
$ /opt/gcc-nightly/12/bin/gcc -mcpu=power10 -O3 aa.c -S
aa.c: In function 'array_crash':
aa.c:2:17: internal compiler error: in count_type_elements, at expr.cc:6407
2 |   __vector_quad arr[2] = {*a, *b}; // Should not crash
  | ^~~
0x105583df count_type_elements
/home/gccbuild/gcc_12_git/gcc/gcc/expr.cc:6407
0x1055cd3b categorize_ctor_elements_1
/home/gccbuild/gcc_12_git/gcc/gcc/expr.cc:6519
0x10646293 gimplify_init_constructor
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:5179
0x10647643 gimplify_modify_expr
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:6040
0x10639d93 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:15098
0x10643fd3 gimplify_stmt(tree_node**, gimple**)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:7151
0x10643fd3 gimplify_and_add(tree_node*, gimple**)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:496
0x10643fd3 gimplify_decl_expr
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:1936
0x1063ad0b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:15295
0x10642b6f gimplify_stmt(tree_node**, gimple**)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:7151
0x10642b6f gimplify_bind_expr
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:1428
0x1063a79b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:15299
0x1063e3d7 gimplify_stmt(tree_node**, gimple**)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:7151
0x1063e3d7 gimplify_body(tree_node*, bool)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:16355
0x1063e83b gimplify_function_tree(tree_node*)
/home/gccbuild/gcc_12_git/gcc/gcc/gimplify.cc:16509
0x1044cab7 cgraph_node::analyze()
/home/gccbuild/gcc_12_git/gcc/gcc/cgraphunit.cc:676
0x1044fbf7 analyze_functions
/home/gccbuild/gcc_12_git/gcc/gcc/cgraphunit.cc:1241
0x10450893 symbol_table::finalize_compilation_unit()
/home/gccbuild/gcc_12_git/gcc/gcc/cgraphunit.cc:2501
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

Version:
$ /opt/gcc-nightly/12/bin/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.

[Bug c/106015] New: [PowerPC] pointer to MMA accumulator not convertible to char pointer

2022-06-17 Thread nemanja.i.ibm at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106015

Bug ID: 106015
   Summary: [PowerPC] pointer to MMA accumulator not convertible
to char pointer
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nemanja.i.ibm at gmail dot com
  Target Milestone: ---

Code:
$ cat aa.c 
unsigned char *conv(__vector_quad *a) {
  return (unsigned char *)a;
}

Compile:
gcc -mcpu=power10 -O3 aa.c -S
aa.c:2:3: error: invalid conversion from type '* __vector_quad'
2 |   return (unsigned char *)a;
  |   ^~

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.