Mesa (master): nir: replace GCC unroll with an option that works on GCC < 8.0

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 28 05:07:07 UTC 2020


Module: Mesa
Branch: master
Commit: d18d07c9d786d484a7fc05d17a17f58209f625f9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d18d07c9d786d484a7fc05d17a17f58209f625f9

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Wed Feb 26 16:57:37 2020 -0500

nir: replace GCC unroll with an option that works on GCC < 8.0

Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3970>

---

 src/compiler/nir/nir_range_analysis.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c
index fdce434054c..548123be4ce 100644
--- a/src/compiler/nir/nir_range_analysis.c
+++ b/src/compiler/nir/nir_range_analysis.c
@@ -220,17 +220,23 @@ analyze_constant(const struct nir_alu_instr *instr, unsigned src,
 
 
 #if defined(__clang__)
-/* clang wants _Pragma("unroll X") */
-#define pragma_unroll_5 _Pragma("unroll 5")
-#define pragma_unroll_7 _Pragma("unroll 7")
+   /* clang wants _Pragma("unroll X") */
+   #define pragma_unroll_5 _Pragma("unroll 5")
+   #define pragma_unroll_7 _Pragma("unroll 7")
 /* gcc wants _Pragma("GCC unroll X") */
 #elif defined(__GNUC__)
-#define pragma_unroll_5 _Pragma("GCC unroll 5")
-#define pragma_unroll_7 _Pragma("GCC unroll 7")
+   #if __GNUC__ >= 8
+      #define pragma_unroll_5 _Pragma("GCC unroll 5")
+      #define pragma_unroll_7 _Pragma("GCC unroll 7")
+   #else
+      #pragma GCC optimize ("unroll-loops")
+      #define pragma_unroll_5
+      #define pragma_unroll_7
+   #endif
 #else
-/* MSVC doesn't have C99's _Pragma() */
-#define pragma_unroll_5
-#define pragma_unroll_7
+   /* MSVC doesn't have C99's _Pragma() */
+   #define pragma_unroll_5
+   #define pragma_unroll_7
 #endif
 
 



More information about the mesa-commit mailing list