diff --git a/gcc/config/or1k/or1k.cc b/gcc/config/or1k/or1k.cc index 17240e3ee48..66fd784f8b9 100644 --- a/gcc/config/or1k/or1k.cc +++ b/gcc/config/or1k/or1k.cc @@ -1389,10 +1389,11 @@ or1k_trampoline_init (rtx m_tramp, tree fndecl, rtx chain) static bool or1k_hard_regno_mode_ok (unsigned int regno, machine_mode mode) { - /* For OpenRISC, GENERAL_REGS can hold anything, while - FLAG_REGS are really single bits within SP[SR]. */ + /* For OpenRISC, GENERAL_REGS can hold anything, while FLAG_REGS are + really single bits within SP[SR]. Also allow condition flag register + in SImode to match or1k_can_change_mode_class. */ if (REGNO_REG_CLASS (regno) == FLAG_REGS) - return mode == BImode; + return mode == BImode || mode == SImode; return true; } diff --git a/gcc/testsuite/gcc.target/or1k/pr125155.c b/gcc/testsuite/gcc.target/or1k/pr125155.c new file mode 100644 index 00000000000..8ca95475b66 --- /dev/null +++ b/gcc/testsuite/gcc.target/or1k/pr125155.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int __pthread_keys_0_0; +int +___pthread_key_delete (void) +{ + int result = 22; + int __atg3_old = 0; + if (__atomic_compare_exchange_n (&__pthread_keys_0_0, &__atg3_old, + 0, 0, 2, 0)) + result = 0; + return result; +}