Bug 72853 - gcc/testsuite/gcc.c-torture/execute/20021120-1.c generates incorrect stxssp op with -mcpu=power9
Summary: gcc/testsuite/gcc.c-torture/execute/20021120-1.c generates incorrect stxssp o...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.2.0
: P3 normal
Target Milestone: 6.2
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2016-08-09 16:36 UTC by acsawdey
Modified: 2016-08-10 18:17 UTC (History)
5 users (show)

See Also:
Host:
Target: powerpc64le-*-*
Build:
Known to work: 6.1.0
Known to fail: 6.2.0, 7.0
Last reconfirmed: 2016-08-09 00:00:00


Attachments
preprocessed version of 20021120-1.c (862 bytes, text/plain)
2016-08-09 16:36 UTC, acsawdey
Details
Proposed patch to fix the problem (294 bytes, text/plain)
2016-08-09 18:00 UTC, Michael Meissner
Details
Proposed patch to fix the problem #2 (1.43 KB, text/plain)
2016-08-09 22:30 UTC, Michael Meissner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description acsawdey 2016-08-09 16:36:55 UTC
Created attachment 39088 [details]
preprocessed version of 20021120-1.c

Compiling the test case with options:

-mcpu=power9 -fno-diagnostics-show-caret -fdiagnostics-color=never -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions -w -lm -o ./20021120-1.exe

Results in 

/tmp/cc9aoc1f.s: Assembler messages:
/tmp/cc9aoc1f.s:552: Error: operand out of domain (30 is not a multiple of 4)
/tmp/cc9aoc1f.s:552: Error: syntax error; found `,', expected `('
/tmp/cc9aoc1f.s:552: Error: junk at end of line: `,24'

The compiler is gcc-6-branch svn version 239277.
Comment 1 Michael Meissner 2016-08-09 17:27:36 UTC
I believe this is a duplicate of PR 72802 that Alan fixed on August 8th for trunk (subversion id 239233), and backported to the gcc-6-branch (subversion id 239269)
Comment 2 Michael Meissner 2016-08-09 18:00:40 UTC
Created attachment 39090 [details]
Proposed patch to fix the problem

Alan mixed up the stxsspx and stxssp alternatives.  I haven't yet done the bootstrap and make check on this patch.
Comment 3 Peter Bergner 2016-08-09 20:03:19 UTC
Confirmed and this is a regression from 6.1.
Comment 4 Michael Meissner 2016-08-09 22:30:51 UTC
Created attachment 39092 [details]
Proposed patch to fix the problem #2

I was looking at the wrong line of assembly in the previous patch.

This patches adds a check for the address being offsettable.  In the movdf patterns, the ISA 3.0 d-form (reg+offset) address alternatives (stxsd, lxsd) come before the ISA 2.06 x-form (reg+reg) alternatives (stxsdx, lxsdx).  So if an indexed address using the Altivec regsiters is emitted when -mcpu=power9 is used, the compiler will emit an illegal instruction.
Comment 5 Alan Modra 2016-08-10 01:32:39 UTC
Yeah, Alan did mess up here in removing offsettable_address_p from the wY constraint.  It wasn't entirely accidental either.  I'd intended to add a simpler test in mem_operand_ds_form to replace it.

Mike, shouldn't the test in your fix be
  if (!offsettable_address_p (false, mode, addr))
ie. *not* strict?

See tm-constrs.h "o" constraint test:

static inline bool
satisfies_constraint_o (rtx op)
{
  return (GET_CODE (op) == MEM) && (
#line 32 "/home/alan/src/gcc.git/gcc/common.md"
(offsettable_nonstrict_memref_p (op)));
}
Comment 6 Michael Meissner 2016-08-10 13:49:45 UTC
Author: meissner
Date: Wed Aug 10 13:49:12 2016
New Revision: 239325

URL: https://gcc.gnu.org/viewcvs?rev=239325&root=gcc&view=rev
Log:
[gcc]
2016-08-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/72853
	* config/rs6000/rs6000.c (mem_operand_ds_form): Add check for op
	being an offsettable address.

[gcc/testsuite]
2016-08-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/72853
	* gcc.target/powerpc/pr72853.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr72853.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Michael Meissner 2016-08-10 18:16:09 UTC
Author: meissner
Date: Wed Aug 10 18:15:37 2016
New Revision: 239331

URL: https://gcc.gnu.org/viewcvs?rev=239331&root=gcc&view=rev
Log:
Backport from mainline:

[gcc]
2016-08-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/72853
	* config/rs6000/rs6000.c (mem_operand_ds_form): Add check for op
	being an offsettable address.

[gcc/testsuite]
2016-08-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/72853
	* gcc.target/powerpc/pr72853.c: New test.


Added:
    branches/gcc-6-branch/gcc/testsuite/gcc.target/powerpc/pr72853.c
      - copied unchanged from r239330, trunk/gcc/testsuite/gcc.target/powerpc/pr72853.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 8 Michael Meissner 2016-08-10 18:17:11 UTC
Fixed in trunk (subversion id 239325) and gcc-6-branch (subversion id 239331).