From 8287dbce7bcb7c6b1a0aa45f05b8c94a25a7c723 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 10 Mar 2016 23:58:44 +0000 Subject: [PATCH] re PR target/70168 (Wrong code generation in __sync_val_compare_and_swap on PowerPC) PR target/70168 * config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap): Handle overlapping retval and newval. From-SVN: r234126 --- gcc/ChangeLog | 6 ++++++ gcc/config/rs6000/rs6000.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d53c261bb812..cc91e84d61b8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-03-10 Ulrich Weigand + + PR target/70168 + * config/rs6000/rs6000.c (rs6000_expand_atomic_compare_and_swap): + Handle overlapping retval and newval. + 2016-03-10 Nick Clifton PR target/7044 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 5b03f9e7d37f..fd4b7cc5a7ee 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -22283,6 +22283,9 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[]) 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; -- 2.43.5