Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-inc memory access generation for -Os -Oz and -Og #58

Closed
jeremybennett opened this issue Jul 28, 2023 · 6 comments
Closed

Post-inc memory access generation for -Os -Oz and -Og #58

jeremybennett opened this issue Jul 28, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@jeremybennett
Copy link
Collaborator

The support for post-increment addressing in #57 does not generate these instructions for -Os, -Oz or -Og. This issues captures the need to add this functionality.

@jeremybennett jeremybennett added the enhancement New feature or request label Jul 28, 2023
@craigblackmore
Copy link
Collaborator

For https://github.com/openhwgroup/corev-gcc/blob/035c7190d3f89e5f96bf87f5b1030f76ea62f89d/gcc/testsuite/gcc.target/riscv/cv-mem-lw-compile-1.c, gcc -Os and Oz does not generate code that is amenable to transforming to post inc. This is due to:

/* Avoid loop header copying when optimizing for size unless we can
determine that the loop condition is static in the first
iteration. */
if (optimize_loop_for_size_p (loop)
&& !loop->force_vectorize
&& !entry_loop_condition_is_static (loop, ranger))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file,
" Not duplicating bb %i: optimizing for size.\n",
header->index);
continue;
}

You could try changing the loop limit in the test to a compile time constant e.g. change i<n to i<200.

@MaryBennett
Copy link
Collaborator

Thank you, changing from n to 200 works if the c extension is included. I'll add this for cv-mem-*-compile-[1,2].c.

@MaryBennett
Copy link
Collaborator

For now, we will mark Os, Oz, and Og as UNSUPPORTED.

@MaryBennett
Copy link
Collaborator

Could the volatile key word help?

MaryBennett pushed a commit to MaryBennett/corev-gcc that referenced this issue Jan 16, 2024
Partial fix for issue openhwgroup#58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
MaryBennett pushed a commit to MaryBennett/corev-gcc that referenced this issue Jan 16, 2024
Partial fix for issue openhwgroup#58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
@MaryBennett
Copy link
Collaborator

Thank you, changing from n to 200 works if the c extension is included. I'll add this for cv-mem-*-compile-[1,2].c.

This is done in PR #96.
It does not change the need for Og.

MaryBennett pushed a commit that referenced this issue Jan 19, 2024
Partial fix for issue #58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
MaryBennett pushed a commit to MaryBennett/corev-gcc that referenced this issue Jan 25, 2024
Partial fix for issue openhwgroup#58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
MaryBennett pushed a commit to MaryBennett/corev-gcc that referenced this issue Jan 25, 2024
Partial fix for issue openhwgroup#58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
MaryBennett pushed a commit to MaryBennett/corev-gcc that referenced this issue Jan 25, 2024
Partial fix for issue openhwgroup#58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
simonpcook pushed a commit to simonpcook/corev-gcc that referenced this issue Feb 29, 2024
Partial fix for issue openhwgroup#58 and tidy up

Files Changed:

  * cv-mem-lb-compile-1.c
  * cv-mem-lb-compile-2.c
  * cv-mem-lb-compile-3.c
  * cv-mem-lbu-compile-1.c
  * cv-mem-lbu-compile-2.c
  * cv-mem-lbu-compile-3.c
  * cv-mem-lh-compile-1.c
  * cv-mem-lh-compile-2.c
  * cv-mem-lh-compile-3.c
  * cv-mem-lhu-compile-1.c
  * cv-mem-lhu-compile-2.c
  * cv-mem-lhu-compile-3.c
  * cv-mem-lw-compile-1.c
  * cv-mem-lw-compile-2.c
  * cv-mem-lw-compile-3.c
  * cv-mem-sb-compile-1.c
  * cv-mem-sb-compile-2.c
  * cv-mem-sb-compile-3.c
  * cv-mem-sh-compile-1.c
  * cv-mem-sh-compile-2.c
  * cv-mem-sh-compile-3.c
  * cv-mem-sw-compile-1.c
  * cv-mem-sw-compile-2.c
  * cv-mem-sw-compile-3.c
jeremybennett pushed a commit that referenced this issue May 29, 2024
In PR 113907 comment #58, Honza found a case where ICF thinks bodies
of functions are equivalent but becaise of difference in aliases in a
memory access, different aggregate jump functions are associated with
supposedly equivalent call statements.  This patch adds a way to
compare jump functions and plugs it into ICF to avoid the issue.

gcc/ChangeLog:

2024-03-20  Martin Jambor  <[email protected]>

	PR ipa/113907
	* ipa-prop.h (class ipa_vr): Declare new overload of a member function
	equal_p.
	(ipa_jump_functions_equivalent_p): Declare.
	* ipa-prop.cc (ipa_vr::equal_p): New function.
	(ipa_agg_pass_through_jf_equivalent_p): Likewise.
	(ipa_agg_jump_functions_equivalent_p): Likewise.
	(ipa_jump_functions_equivalent_p): Likewise.
	* ipa-cp.h (values_equal_for_ipcp_p): Declare.
	* ipa-cp.cc (values_equal_for_ipcp_p): Make function public.
	* ipa-icf-gimple.cc: Include alloc-pool.h, symbol-summary.h, sreal.h,
	ipa-cp.h and ipa-prop.h.
	(func_checker::compare_gimple_call): Comapre jump functions.

gcc/testsuite/ChangeLog:

2024-03-20  Martin Jambor  <[email protected]>

	PR ipa/113907
	* gcc.dg/lto/pr113907_0.c: New.
	* gcc.dg/lto/pr113907_1.c: Likewise.
	* gcc.dg/lto/pr113907_2.c: Likewise.
@MaryBennett
Copy link
Collaborator

Moved to new issue #108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants