Bug 416667 - gcc10 ppc64le impossible constraint in 'asm' in test_isa
Summary: gcc10 ppc64le impossible constraint in 'asm' in test_isa
Status: CLOSED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-23 21:19 UTC by Mark Wielaard
Modified: 2020-01-29 16:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch, fix assembler constraints (3.24 KB, patch)
2020-01-24 19:28 UTC, Carl Love
Details
GCC10 ppc64 asm constrainst update (3.49 KB, text/plain)
2020-01-25 00:07 UTC, Mark Wielaard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2020-01-23 21:19:55 UTC
With GCC10 (not out yet, but already used in fedora rawhide) we get:

test_isa_2_07_part1.c: In function 'test_mfvsrd':
test_isa_2_07_part1.c:388:4: error: impossible constraint in 'asm'
  388 |    __asm__ __volatile__ ("mfvsrd %0,%x1" : "=r" (r14) : "ws" (vec_inA));
      |    ^~~~~~~

test_isa_3_0.c: In function 'test_xscmpeqdp':
test_isa_3_0.c:1181:4: error: impossible constraint in 'asm'
 1181 |    __asm__ __volatile__ ("xscmpeqdp   %x0, %x1, %x2 " : "+wa" (vec_xt): "ww" (vec_xa), "ww" (vec_xb));
      |    ^~~~~~~

https://kojipkgs.fedoraproject.org//work/tasks/9655/40929655/build.log
Comment 1 Carl Love 2020-01-23 22:09:03 UTC
Mark:

I copied the two tests into a file and tried compiling them on a GCC10 compiler I have available.  I was able to reproduce the first issue but not the second.  I sent email to the compiler team about the issue.  Wondering if there is an assembler change causing the issue.  

Anyway, just wanted to let you know I saw your bug and am looking into it.
Comment 2 Julian Seward 2020-01-23 22:17:51 UTC
(In reply to Carl Love from comment #1)

Carl,

> I was able to reproduce the first issue but not
> the second.  I sent email to the compiler team about the issue.  Wondering
> if there is an assembler change causing the issue.  

I wouldn't have thought this was an assembler issue; the complaint occurs
before assembly code is ever produced.

I wonder if it might be to do with compiler optimisation level though.  Can
you reproduce it at any of -O0, -Og, -O1, -O2, -O3 ?
Comment 3 Carl Love 2020-01-23 22:46:29 UTC
Julian:

I hadn't thought to try different optimizations.  I can reproduce the issue for the mfvsrd test only with no optimizations.  No errors are reported with -O1, -O2 and -O3 optimization levels.

$GCC_INSTALL/bin/gcc  -c valgrind-bug.c
valgrind-bug.c: In function ‘test_mfvsrd’:
valgrind-bug.c:19:4: error: impossible constraint in ‘asm’
   19 |    __asm__ __volatile__ ("mfvsrd %0,%x1" : "=r" (r14) : "ws" (vec_inA));
      |    ^~~~~~~

$GCC_INSTALL/bin/gcc -O0 -c valgrind-bug.c
valgrind-bug.c: In function ‘test_mfvsrd’:
valgrind-bug.c:19:4: error: impossible constraint in ‘asm’
   19 |    __asm__ __volatile__ ("mfvsrd %0,%x1" : "=r" (r14) : "ws" (vec_inA));
      |    ^~~~~~~

~/Valgrind$ $GCC_INSTALL/bin/gcc -O1 -c valgrind-bug.c

~/Valgrind$ $GCC_INSTALL/bin/gcc -O2 -c valgrind-bug.c

~/Valgrind$ $GCC_INSTALL/bin/gcc -O3 -c valgrind-bug.c
Comment 4 Carl Love 2020-01-23 22:57:24 UTC
Julian, Mark:

Looks like it is a GCC change.  

Per the message from Will

It's related to some cleanups that Segher did last year. 

git show cc998fd5f43a296e1a12bf4de63c4c9dd1d39cfa
git show 208a040511b9c4d9a59af1caafa855a031a7a0ca
git show 0d0863136f59e7f937f60c772921bc73708fba81

   "ws" is just "wa".
and
   "wv" is "v", but only if VSX is enabled (otherwise it's NO_REGS).
and
    rs6000: ww->wa in testsuite
Comment 5 Carl Love 2020-01-24 19:28:10 UTC
Created attachment 125376 [details]
Patch, fix assembler constraints

The attached patch changes the ww and ws assembler constraints to wa.

Please test this patch in your environment and let me know if it fixes all of the issues.  I am only able to partially reproduce the errors you saw in the initial bug report.  Thanks.
Comment 6 Mark Wielaard 2020-01-25 00:05:21 UTC
With the patch I am still seeing:

test_isa_2_07_part1.c:398:4: error: impossible constraint in 'asm'
  398 |    __asm__ __volatile__ ("mtvsrd %x0,%1" : "=ws" (vec_out) : "r" (r14));
      |    ^~~~~~~

test_isa_3_0.c: In function 'test_xscvdphp':
test_isa_3_0.c:1831:4: error: impossible constraint in 'asm'
 1831 |    __asm__ __volatile__ ("xscvdphp %x0, %x1 " : "+wi" (vec_xt) : "wi" (vec_xb));
      |    ^~~~~~~

I replaced the other "ws" constrainst in test_isa_2_07_part1.c with "wa" too.

For "wi" I found gcc:

commit e670418ff18f36f81f3f619c34578da03d102694
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date:   Tue Jun 4 18:27:45 2019 +0200

    rs6000: wi->wa, wt->wa
    
    "wi" and "wt" mean just the same as "wa" these days.  Change them to
    the simpler name.

And

commit 72e3386e136205dcc69e61e538b94643832cf22a
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date:   Wed Jun 5 01:31:32 2019 +0200

    rs6000: ww -> wa
    
    "ww" can always be "wa".

So I did that in test_isa_3_0.c
Comment 7 Mark Wielaard 2020-01-25 00:07:12 UTC
Created attachment 125383 [details]
GCC10 ppc64 asm constrainst update

The attached patch is what I am testing now and seems to pass the compiler/build.
Comment 8 Mark Wielaard 2020-01-25 20:09:33 UTC
(In reply to Mark Wielaard from comment #7)
> Created attachment 125383 [details]
> GCC10 ppc64 asm constrainst update
> 
> The attached patch is what I am testing now and seems to pass the
> compiler/build.

Which seems to fix the issue. Both test_isa_2_07_part1.c and test_is_3_0.c compile and the tests pass.
Comment 9 Carl Love 2020-01-28 18:23:16 UTC
Mark:

I pulled down and reviewed your version of the patch.  I tested it on PPC64 Power 8 and PPC64 Power 9.  It passed fine on both systems.  Note, the regression suite was compiled with a pre GCC 10 compiler.  I manually compiled the two test cases using a version of the GCC 10 compiler with no issues.

The patch was committed to Valgrind mainline.

commit 4f70aa4fb0d4cef97ee34602d72f3980c5a83bf6
Author: Carl Love <carll@us.ibm.com>
Date:   Tue Jan 28 12:17:16 2020 -0600

    PPC64: Fix assembler constraints.
    
    The PPC64 assembler constraints "ws", "wa" and "ww" have changed to "wa"
    in GCC 10.  Update the ppc64 tests test_isa_2_07_part1.c and test_isa_3_0.c.

I believe the issue can be closed if you agree.
Comment 10 Mark Wielaard 2020-01-29 10:08:01 UTC
(In reply to Carl Love from comment #9)
> commit 4f70aa4fb0d4cef97ee34602d72f3980c5a83bf6
> Author: Carl Love <carll@us.ibm.com>
> Date:   Tue Jan 28 12:17:16 2020 -0600
> 
>     PPC64: Fix assembler constraints.
>     
>     The PPC64 assembler constraints "ws", "wa" and "ww" have changed to "wa"
>     in GCC 10.  Update the ppc64 tests test_isa_2_07_part1.c and
> test_isa_3_0.c.
> 
> I believe the issue can be closed if you agree.

Works for me. Thanks!
Comment 11 Carl Love 2020-01-29 16:12:30 UTC
closed issue