diff --git a/tests/unittests/tests-core/tests-core-atomic.c b/tests/unittests/tests-core/tests-core-atomic.c
index 7089f9edfae83b21fdef6af8dcb3fa2654842f92..f05bab05b683b886f128c715225788d40b46d43d 100644
--- a/tests/unittests/tests-core/tests-core-atomic.c
+++ b/tests/unittests/tests-core/tests-core-atomic.c
@@ -51,7 +51,11 @@ static void test_atomic_inc_negative(void)
         TEST_ASSERT_EQUAL_INT(i + 1, atomic_load(&res));
     }
 }
-
+/* Prevent compiler optimization for SAML1X because of gcc internal bug */
+#ifdef CPU_SAML1X
+#pragma GCC push_options
+#pragma GCC optimize ("O0")
+#endif
 static void test_atomic_inc_rollover(void)
 {
     atomic_int res = ATOMIC_VAR_INIT(INT_MAX - 30);
@@ -67,7 +71,9 @@ static void test_atomic_inc_rollover(void)
     TEST_ASSERT_EQUAL_INT(INT_MIN + 1, atomic_fetch_add(&res, 1));
     TEST_ASSERT_EQUAL_INT(INT_MIN + 2, atomic_load(&res));
 }
-
+#ifdef CPU_SAML1X
+#pragma GCC pop_options
+#endif
 /* Test atomic_fetch_sub */
 static void test_atomic_dec_negative(void)
 {