[Bug c/116540] New: sh ignores asm operand modifier %c

2024-08-30 Thread vegard.nossum at oracle dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116540

Bug ID: 116540
   Summary: sh ignores asm operand modifier %c
   Product: gcc
   Version: 14.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vegard.nossum at oracle dot com
  Target Milestone: ---

According to https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html, %c is a
generic (architecture-independent) operand modifier that is supposed to "print
the constant expression with no punctuation". However, on the sh architecture
the number is still prefixed by "#". Input:

void foo() {
asm volatile (".ascii \"%c0\"" :: "i" (123));
}

Result:

.ascii "#123"

See also: https://godbolt.org/z/8ePq1T4rY

This works correctly on other architectures like x86 and aarch64.

[Bug c/116539] New: internal compiler error: in sh_print_operand, at config/sh/sh.cc:1360

2024-08-30 Thread vegard.nossum at oracle dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116539

Bug ID: 116539
   Summary: internal compiler error: in sh_print_operand, at
config/sh/sh.cc:1360
   Product: gcc
   Version: 14.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vegard.nossum at oracle dot com
  Target Milestone: ---

Test case:

void foo() {
asm volatile (".ascii \"%d0\"" :: "i" (123));
}

Built with sh gcc 14.2.0, gives the following error:

during RTL pass: final
: In function 'foo':
:3:1: internal compiler error: in sh_print_operand, at
config/sh/sh.cc:1360
3 | }
  | ^
0x17a73f8 internal_error(char const*, ...)
???:0
0x6cb3ba fancy_abort(char const*, int, char const*)
???:0
0x94d2e1 output_operand(rtx_def*, int)
???:0
0x94dbb3 output_asm_insn(char const*, rtx_def**)
???:0
0x94f608 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
???:0
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.
Compiler returned: 1

Also see: https://godbolt.org/z/3Tfcdbd9s

I'm aware "d" is probably not a valid modifier for sh, but I'm guessing a more
descriptive error message would be appropriate.

I discovered this completely by accident and I don't actually need a fix for
this myself.

[Bug c/101474] New: -fipa-icf generates worse code for identical function

2021-07-16 Thread vegard.nossum at oracle dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101474

Bug ID: 101474
   Summary: -fipa-icf generates worse code for identical function
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vegard.nossum at oracle dot com
  Target Milestone: ---

Created attachment 51166
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51166&action=edit
Test case

I've come across a weird behaviour when using -fipa-icf, could maybe be related
to bug 80277.

Build with -O1 -fipa-icf and the second version of the identical function
actually has worse codegen than if you have just one of them there or than if
you hadn't passed -fipa-icf at all.

See example: https://godbolt.org/z/n8zz947aK