Bug 440906 - powerpc valgrind testsuite; update test_isa_3_1_common.c to avoid modulo against hard regs
Summary: powerpc valgrind testsuite; update test_isa_3_1_common.c to avoid modulo agai...
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: Carl Love
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-12 20:54 UTC by Will Schmidt
Modified: 2021-10-01 21:09 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
proposed patch to rework modulo operation (1.49 KB, patch)
2021-08-12 20:56 UTC, Will Schmidt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Will Schmidt 2021-08-12 20:54:24 UTC
SUMMARY
Due to a GCC issue (PR101882) seen against recent GCC builds, we
want to rework our code to avoid attempting a modulo operation
with both the input and output defined as a hard register.
ra is earlier defined as
    register uint64_t ra   __asm__  ("r20");
and current code attempts a 
    ra = ra % 9;
In this case, we can apply the modulo operation to the args[] array
value that was previously used to initialize the ra value.
    ra = args[vrai] % 9;

Patch attached.

STEPS TO REPRODUCE
1. Build valgrind for power9 or power10 using a recent (~ Aug 2021) GCC.
2. See "impossible constraint" error emitted from GCC.
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Will Schmidt 2021-08-12 20:56:46 UTC
Created attachment 140674 [details]
proposed patch to rework modulo operation
Comment 2 Carl Love 2021-08-13 22:26:01 UTC
FYI, issue initially seen with the gcc compiler in the AT at-next-16.0-0-alpha build.

Issue reproduced using a build of the GCC compiler from the mainline gcc tree.
Comment 3 Carl Love 2021-09-07 18:37:04 UTC
Proposed patch reviewd, tested and committed.

commit 733aba84822efe101a098446079b4798f1b51faf (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Love <cel@us.ibm.com>
Date:   Fri Sep 3 17:14:50 2021 +0000

    Fix impossible constraint issue in P10 testcase.
    
    This reworks the modulo operation as seen in
    valgrind/none/tests/ppc64/test_isa_3_1_common.c:
      initialize_source_registers().
    
    Due to a GCC issue (PR101882), we will try to avoid a modulo operation with
    both input and outputs set to a hard register. In this case, we can apply
    the modulo operation to the args[] array value used to initialize the ra
    value.
    
    https://bugs.kde.org/show_bug.cgi?id=440906
Comment 4 Carl Love 2021-10-01 21:09:32 UTC
patch committed closing