Mark Wielaard b35e0b
commit 60ff013998de8aa168e01b7b1c1743bcbdee99b1
Mark Wielaard b35e0b
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Mark Wielaard b35e0b
Date:   Thu Aug 12 15:41:50 2021 -0500
Mark Wielaard b35e0b
Mark Wielaard b35e0b
    Hi
Mark Wielaard b35e0b
    
Mark Wielaard b35e0b
      This reworks the modulo operation as seen in
Mark Wielaard b35e0b
    valgrind/none/tests/ppc64/test_isa_3_1_common.c:
Mark Wielaard b35e0b
    initialize_source_registers().   Due to a GCC issue (PR101882), we
Mark Wielaard b35e0b
    will try to avoid a modulo operation with both input and outputs set to
Mark Wielaard b35e0b
    a hard register.
Mark Wielaard b35e0b
      In this case, we can apply the modulo operation to the args[] array
Mark Wielaard b35e0b
    value used to initialize the ra value.
Mark Wielaard b35e0b
Mark Wielaard b35e0b
diff --git a/none/tests/ppc64/test_isa_3_1_common.c b/none/tests/ppc64/test_isa_3_1_common.c
Mark Wielaard b35e0b
index 8222a857fc..7c3dc6f009 100644
Mark Wielaard b35e0b
--- a/none/tests/ppc64/test_isa_3_1_common.c
Mark Wielaard b35e0b
+++ b/none/tests/ppc64/test_isa_3_1_common.c
Mark Wielaard b35e0b
@@ -2261,12 +2261,17 @@ void initialize_source_registers () {
Mark Wielaard b35e0b
       if (has_rb)  rb = 2*vrbi;
Mark Wielaard b35e0b
       /* note special case for is_insert_double, see set_up_iterators () */
Mark Wielaard b35e0b
       if (has_ra)  ra = 4*vrai;
Mark Wielaard b35e0b
       if (is_insert_double) {
Mark Wielaard b35e0b
 	 /* For an insert_double, the results are undefined
Mark Wielaard b35e0b
-	    for ra > 8, so modulo those into a valid range. */
Mark Wielaard b35e0b
-	 ra = ra % 9;
Mark Wielaard b35e0b
+	    for ra > 8, so modulo those into a valid range.
Mark Wielaard b35e0b
+	    Since ra is defined as a hard register, and due to gcc
Mark Wielaard b35e0b
+	    issue (PR101882) where a modulo operation fails with
Mark Wielaard b35e0b
+	    both input and output regs set to a hard register, this
Mark Wielaard b35e0b
+	    assignment references the args[] array again, versus
Mark Wielaard b35e0b
+	    ra = ra % 9;.  */
Mark Wielaard b35e0b
+	 ra = args[vrai] % 9;
Mark Wielaard b35e0b
       }
Mark Wielaard b35e0b
    }
Mark Wielaard b35e0b
 
Mark Wielaard b35e0b
    if (uses_buffer) {
Mark Wielaard b35e0b
       if (has_rb) {