diff options
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 09fefe50..35969ad 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5332,9 +5332,12 @@ expand_builtin_atomic_compare_exchange (enum machine_mode mode, tree exp, if (target == const0_rtx) target = NULL; - oldval = expect; - if (!expand_atomic_compare_and_swap (&target, &oldval, mem, oldval, desired, + /* Lest the rtl backend create a race condition with an imporoper store + to memory, always create a new pseudo for OLDVAL. */ + oldval = NULL; + + if (!expand_atomic_compare_and_swap (&target, &oldval, mem, expect, desired, is_weak, success, failure)) return NULL_RTX; |