Hello,

this patch fixes PR target/70168, a wrong code generation problem
caused by rs6000_expand_atomic_compare_and_swap not properly handling
the case where changing retval clobbers newval due to a register overlap.

Tested with no regressions on powerpc64le-linux on mainline
and gcc-5-branch.

OK for both?

Bye,
Ulrich


ChangeLog:

        PR target/70168
        * config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap):
        Handle overlapping retval and newval.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 234119)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -20740,6 +20740,9 @@
   if (mode != TImode && !reg_or_short_operand (oldval, mode))
     oldval = copy_to_mode_reg (mode, oldval);
 
+  if (reg_overlap_mentioned_p (retval, newval))
+    newval = copy_to_reg (newval);
+
   mem = rs6000_pre_atomic_barrier (mem, mod_s);
 
   label1 = NULL_RTX;
-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com

Reply via email to