Bug 84033 - powerpc64le -moptimize-swaps bad code with vec_vbpermq
Summary: powerpc64le -moptimize-swaps bad code with vec_vbpermq
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2018-01-25 06:29 UTC by Alan Modra
Modified: 2018-03-29 00:54 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc64le-linux
Build:
Known to work:
Known to fail: 5.5.0, 6.4.1, 7.2.1, 8.0
Last reconfirmed: 2018-01-25 00:00:00


Attachments
testcase (334 bytes, text/plain)
2018-01-25 06:29 UTC, Alan Modra
Details
proposed patch (1.43 KB, patch)
2018-01-25 07:28 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2018-01-25 06:29:48 UTC
Created attachment 43235 [details]
testcase

The attached testcase fails on ppc64le with -O2 -mcpu=power8, and passes when -mno-optimize-swaps is used.
Comment 1 Alan Modra 2018-01-25 07:28:02 UTC
Created attachment 43236 [details]
proposed patch

patch under test
Comment 2 Bill Schmidt 2018-01-25 13:28:13 UTC
Thanks for chasing this down, Alan!  The fix looks good to me.
Comment 3 Alan Modra 2018-01-25 23:57:50 UTC
Author: amodra
Date: Thu Jan 25 23:57:18 2018
New Revision: 257070

URL: https://gcc.gnu.org/viewcvs?rev=257070&root=gcc&view=rev
Log:
PR84033, powerpc64le -moptimize-swaps bad code with vec_vbpermq

vbpermq produces its output in bits 48..63 of the target vector reg,
so the output cannot be lane swapped.

gcc/
	PR target/84033
	* config/rs6000/rs6000-p8swap.c (rtx_is_swappable_p): Exclude
	UNSPEC_VBPERMQ.  Sort other unspecs.
gcc/testsuite/
	PR target/84033
	* gcc.target/powerpc/swaps-p8-46.c: New.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000-p8swap.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Alan Modra 2018-01-29 04:23:32 UTC
Author: amodra
Date: Mon Jan 29 04:23:00 2018
New Revision: 257135

URL: https://gcc.gnu.org/viewcvs?rev=257135&root=gcc&view=rev
Log:
PR84033, powerpc64le -moptimize-swaps bad code with vec_vbpermq

vbpermq produces its output in bits 48..63 of the target vector reg,
so the output cannot be lane swapped.

gcc/
	PR target/84033
	* config/rs6000/rs6000.c (rtx_is_swappable_p): Exclude
	UNSPEC_VBPERMQ.
gcc/testsuite/
	PR target/84033
	* gcc.target/powerpc/swaps-p8-46.c: New.

Backport svn r257070

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/config/rs6000/rs6000.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 5 Alan Modra 2018-01-29 04:31:50 UTC
Author: amodra
Date: Mon Jan 29 04:31:18 2018
New Revision: 257137

URL: https://gcc.gnu.org/viewcvs?rev=257137&root=gcc&view=rev
Log:
[PATCH] PR84033, powerpc64le -moptimize-swaps bad code with vec_vbpermq

vbpermq produces its output in bits 48..63 of the target vector reg,
so the output cannot be lane swapped.

gcc/
	PR target/84033
	* config/rs6000/rs6000.c (rtx_is_swappable_p): Exclude
	UNSPEC_VBPERMQ.
gcc/testsuite/
	PR target/84033
	* gcc.target/powerpc/swaps-p8-46.c: New.

Backport svn r257070

Added:
    branches/gcc-6-branch/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/config/rs6000/rs6000.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 6 Alan Modra 2018-01-29 04:33:55 UTC
Fixed all active branches
Comment 7 Breno Leitao 2018-03-28 12:39:59 UTC
Hi Alan,

I was not able to read the changelog and understand what are the exact versions that this bug is fixed. How can I read and get this information?

I am asking this question because mongodb was hitting this issue[1], and the workaround was disabling optimization[2] during mongodb compilation.

That said, we would like to re-enable the optimized compilation for mongodb[3], but we need this GCC fix on the distros first, so, I need to know which GCC version contains this fix and migrating to it prior to the re-enablement of the Mongodb optimization.

I understand that this fix didn't make the GCC 8 first release, thus, there was a minor version update on GCC 6, 7 and 8 that contains this fix. Is my understanding correct?

Thank you,
Breno

[1] https://jira.mongodb.org/browse/SERVER-33395
[2] https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/1758116
[3] https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/1758118
Comment 8 Alan Modra 2018-03-29 00:54:38 UTC
Hi Breno, the first gcc-8 has not yet been released (current aim is for a release mid April), nor has there been a release from the gcc-7 or gcc-6 branches containing this bug fix.  I missed out on gcc-7.3 by a few days.

Incidentally, https://gcc.gnu.org/develop.html#timeline is a useful page giving history of gcc releases.