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

Not an issue, but somewhere to post test results. #1

Open
iains opened this issue Apr 28, 2023 · 14 comments
Open

Not an issue, but somewhere to post test results. #1

iains opened this issue Apr 28, 2023 · 14 comments

Comments

@iains
Copy link
Owner

iains commented Apr 28, 2023

No description provided.

iains pushed a commit that referenced this issue May 21, 2023
Hi all,

We noticed that calls to the vadcq and vsbcq intrinsics, both of
which use __builtin_arm_set_fpscr_nzcvqc to set the Carry flag in
the FPSCR, would produce the following code:

```
< r2 is the *carry input >
vmrs	r3, FPSCR_nzcvqc
bic	r3, r3, #536870912
orr	r3, r3, r2, lsl #29
vmsr	FPSCR_nzcvqc, r3
```

when the MVE ACLE instead gives a different instruction sequence of:
```
< Rt is the *carry input >
VMRS Rs,FPSCR_nzcvqc
BFI Rs,Rt,#29,#1
VMSR FPSCR_nzcvqc,Rs
```

the bic + orr pair is slower and it's also wrong, because, if the
*carry input is greater than 1, then we risk overwriting the top two
bits of the FPSCR register (the N and Z flags).

This turned out to be a problem in the header file and the solution was
to simply add a `& 1x0u` to the `*carry` input: then the compiler knows
that we only care about the lowest bit and can optimise to a BFI.

Ok for trunk?

Thanks,
Stam Markianos-Wright

gcc/ChangeLog:

	* config/arm/arm_mve.h (__arm_vadcq_s32): Fix arithmetic.
	(__arm_vadcq_u32): Likewise.
	(__arm_vadcq_m_s32): Likewise.
	(__arm_vadcq_m_u32): Likewise.
	(__arm_vsbcq_s32): Likewise.
	(__arm_vsbcq_u32): Likewise.
	(__arm_vsbcq_m_s32): Likewise.
	(__arm_vsbcq_m_u32): Likewise.
	* config/arm/mve.md (get_fpscr_nzcvqc): Make unspec_volatile.

gcc/testsuite/ChangeLog:
	* gcc.target/arm/mve/mve_vadcq_vsbcq_fpscr_overwrite.c: New.
@ilg-ul
Copy link

ilg-ul commented Jun 4, 2024

I would like to give it a try, but I don't know what commits should I add to the Homebrew patches, the only recent commit I can find is a README update.

@iains
Copy link
Owner Author

iains commented Jun 4, 2024

I would like to give it a try, but I don't know what commits should I add to the Homebrew patches, the only recent commit I can find is a README update.

9fd551b is the relevant commit.

Hmmmm.. let me check this, something appears to have gone wrong.

@iains
Copy link
Owner Author

iains commented Jun 4, 2024

hmm now I am confused - that patch is in the 13.3-darwin-r0 release .. so it should be (AFAIK) in the Homebrew kit - @fxcoudert ? [so the r1 is actually unnecessary :( .. ]

please could you try just building the 13.3-darwin-r{0,1} branch and check if your issue is resolved - I cannot realistically check more than the trees I produce.

@ilg-ul
Copy link

ilg-ul commented Jun 4, 2024

9fd551b is the relevant commit.

Perhaps I'm missing something, but this commit seems to change only some comments:

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index 266c76df1d3..3749d8b7b3e 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  May 22, 2024 at 10:16:02 AM by AutoGen 5.18.7
+ * It has been AutoGen-ed  June  1, 2024 at 05:24:18 PM by AutoGen 5.18.7
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Wed May 22 10:16:02 BST 2024
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jun  1 17:24:18 BST 2024
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
-- 
2.39.3 (Apple Git-146)

@iains
Copy link
Owner Author

iains commented Jun 4, 2024

9fd551b is the relevant commit.

Perhaps I'm missing something, but this commit seems to change only some comments:

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index 266c76df1d3..3749d8b7b3e 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  May 22, 2024 at 10:16:02 AM by AutoGen 5.18.7
+ * It has been AutoGen-ed  June  1, 2024 at 05:24:18 PM by AutoGen 5.18.7
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Wed May 22 10:16:02 BST 2024
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jun  1 17:24:18 BST 2024
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
-- 
2.39.3 (Apple Git-146)

correct - because the patch had already been applied as : 8543cc2

So that all the reapplication did was to update the generation date info.

So - 13.3-darwin-r0 contains this fix; (as does 13.3-darwin-r1) therefore, please build one of those trees and confirm (or not) that your problem is fixed.

@ilg-ul
Copy link

ilg-ul commented Jun 4, 2024

So - 13.3-darwin-r0 contains this fix

The gcc@13.rb file includes a link to:

I searched for fixincl.x in that file and there is only one occurrence which is not a diff file name, so it seems that the file is not fixed in Homebrew.

@fxcoudert
Copy link
Contributor

fxcoudert commented Jun 4, 2024

@ilg-ul the fix is not in Homebrew so far. Homebrew builds binaries for each macOS version (and matching SDK) separately, so the issue is not as problematic for us as it can be for a single binary distribution targeting multiple macOS versions.

Iain has linked the commit that you need to apply.

@ilg-ul
Copy link

ilg-ul commented Jun 4, 2024

So the Homebrew patch is not based on the 13.3-darwin-r0 tag?

@iains
Copy link
Owner Author

iains commented Jun 4, 2024

So the Homebrew patch is not based on the 13.3-darwin-r0 tag?

"based on" != "identical" I think - HB omits the testsuite changes, for example.

@fxcoudert
Copy link
Contributor

So the Homebrew patch is not based on the 13.3-darwin-r0 tag?

It is based on the pre-release, which is almost the same, but did not include the fixincludes removal. I plan to include that eventually, and am testing it on GCC 14 first: Homebrew/homebrew-core#173647

And yes, based on != identical. Each distributor (Homebrew like others) makes choices for distribution, based on their needs and constraints.

@ilg-ul
Copy link

ilg-ul commented Jun 4, 2024

I see, I assumed that the HB patches use exactly the commits tagged by Iain, like 13.3-darwin-r0.

I prepared a patch like this:

git diff origin/gcc-13-3..fa196a8618c62428a372fb251f9fa292d4f275c2

(the numeric commit sha will eventually become 13.3-darwin-r1)

Apart from the testsuite commits which are not relevant to me, are there any other commits that you exclude when preparing the patch for the HB distribution?

I'm trying to identify a way to create these patches in order to remain functionally compatible with the HB releases.

@ilg-ul
Copy link

ilg-ul commented Jun 4, 2024

With the updated patch the problem related to the availability macros seems fixed.

There is only one test failing in certain conditions, both for 14.a and 13.3, I'll prepare a separate issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants