diff --git a/libraries/AP_IOMCU/iofirmware/iofirmware.cpp b/libraries/AP_IOMCU/iofirmware/iofirmware.cpp
index 9bc91db920..606faf1bd2 100644
--- a/libraries/AP_IOMCU/iofirmware/iofirmware.cpp
+++ b/libraries/AP_IOMCU/iofirmware/iofirmware.cpp
@@ -32,7 +32,7 @@ extern const AP_HAL::HAL &hal;
// we build this file with optimisation to lower the interrupt
// latency. This helps reduce the chance of losing an RC input byte
// due to missing a UART interrupt
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
static AP_IOMCU_FW iomcu;
diff --git a/libraries/AP_Math/matrix3.cpp b/libraries/AP_Math/matrix3.cpp
index 5cd4129d8f..fa8e4dd6e9 100644
--- a/libraries/AP_Math/matrix3.cpp
+++ b/libraries/AP_Math/matrix3.cpp
@@ -16,7 +16,7 @@
* with this program. If not, see .
*/
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#include "AP_Math.h"
diff --git a/libraries/AP_Math/matrixN.cpp b/libraries/AP_Math/matrixN.cpp
index 0d63a0998a..f5de021ff7 100644
--- a/libraries/AP_Math/matrixN.cpp
+++ b/libraries/AP_Math/matrixN.cpp
@@ -2,7 +2,7 @@
* N dimensional matrix operations
*/
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#include "matrixN.h"
diff --git a/libraries/AP_Math/matrix_alg.cpp b/libraries/AP_Math/matrix_alg.cpp
index 6e4633955e..6f6c22c8a4 100644
--- a/libraries/AP_Math/matrix_alg.cpp
+++ b/libraries/AP_Math/matrix_alg.cpp
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#include
diff --git a/libraries/AP_Math/polygon.cpp b/libraries/AP_Math/polygon.cpp
index 32250e23da..fa5f348e9f 100644
--- a/libraries/AP_Math/polygon.cpp
+++ b/libraries/AP_Math/polygon.cpp
@@ -18,7 +18,7 @@
#include "AP_Math.h"
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
/*
* The point in polygon algorithm is based on:
diff --git a/libraries/AP_Math/quaternion.cpp b/libraries/AP_Math/quaternion.cpp
index cae8b4a781..f7677740b3 100644
--- a/libraries/AP_Math/quaternion.cpp
+++ b/libraries/AP_Math/quaternion.cpp
@@ -16,7 +16,7 @@
* with this program. If not, see .
*/
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#include "AP_Math.h"
diff --git a/libraries/AP_Math/vector2.cpp b/libraries/AP_Math/vector2.cpp
index 500bffdd44..a0c4fa219b 100644
--- a/libraries/AP_Math/vector2.cpp
+++ b/libraries/AP_Math/vector2.cpp
@@ -16,7 +16,7 @@
* with this program. If not, see .
*/
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#include "AP_Math.h"
diff --git a/libraries/AP_Math/vector3.cpp b/libraries/AP_Math/vector3.cpp
index c868820a8d..a23fbfbb10 100644
--- a/libraries/AP_Math/vector3.cpp
+++ b/libraries/AP_Math/vector3.cpp
@@ -16,7 +16,7 @@
* with this program. If not, see .
*/
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#include "AP_Math.h"
diff --git a/libraries/AP_Mount/SoloGimbalEKF.cpp b/libraries/AP_Mount/SoloGimbalEKF.cpp
index 52b386d29e..c288cfd989 100644
--- a/libraries/AP_Mount/SoloGimbalEKF.cpp
+++ b/libraries/AP_Mount/SoloGimbalEKF.cpp
@@ -5,7 +5,7 @@
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#pragma GCC optimize("O0")
#else
-#pragma GCC optimize("O3")
+#pragma GCC optimize("O2")
#endif
#include "SoloGimbalEKF.h"