0025-gcc-testsuite-tweaks-for-mips-OE.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. From f12acc6a383546d48da3bdfb2f25ca2adb7976d7 Mon Sep 17 00:00:00 2001
  2. From: Richard Purdie <richard.purdie@linuxfoundation.org>
  3. Date: Sun, 13 Aug 2023 10:24:05 +0100
  4. Subject: [PATCH] gcc testsuite tweaks for mips/OE
  5. Disable loongson-mmi runtine, qemu doesn't appear to fully support them even if some
  6. of the instruction decoding is there.
  7. Also disable MSA mips runtime extensions. For some reason qemu appears to accept the test
  8. code when it shouldn't. Our selected MIPS cpu for QEMU doesn't support them.
  9. MIPS is unusual in the gcc testsuite as it uses EFFECTIVE_TARGETS and loops
  10. multiple times through the vector testsuite. In the case of the two above, we can
  11. compile/link them but not run them. Even with the runtime disabled, if the code
  12. marks it as a runtime test, it will elevate itself to that. Setting the default
  13. target to compile therefore isn't enough.
  14. Therefore add code to downgrade runtime tests to link tests if the hardware
  15. support isn't there to run them. This avoids thousands of test failures. To do
  16. this we have to hook downgrade code into the main test runner.
  17. Enable that downgrading for other cases where hardware to run vector extensions is
  18. unavailable to remove test failures on other architectures too.
  19. Also, for gcc.target tests, add checks on wheter loongson or msa code can
  20. be run before trying that, allowing downgrading of tests there to work too.
  21. Upstream-Status: Pending
  22. [Parts of the patch may be able to be split off and acceptable to upstream with
  23. discussion. Need to investigate why qemu-user passes the 'bad' instructions']
  24. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
  25. ---
  26. gcc/testsuite/gcc.target/mips/mips.exp | 16 +++++++++
  27. gcc/testsuite/lib/gcc-dg.exp | 11 +++++++
  28. gcc/testsuite/lib/target-supports.exp | 45 ++++++++------------------
  29. 3 files changed, 41 insertions(+), 31 deletions(-)
  30. diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
  31. index 15d574202d3..2cef9709774 100644
  32. --- a/gcc/testsuite/gcc.target/mips/mips.exp
  33. +++ b/gcc/testsuite/gcc.target/mips/mips.exp
  34. @@ -709,7 +709,23 @@ proc mips_first_unsupported_option { upstatus } {
  35. global mips_option_tests
  36. upvar $upstatus status
  37. + if { [mips_have_test_option_p status "-mmsa"] } {
  38. + verbose -log "Found -mmsa"
  39. + if { ![check_mips_msa_hw_available] } {
  40. + verbose -log "No MSA avail"
  41. + return "-mmsa"
  42. + }
  43. + }
  44. + if { [mips_have_test_option_p status "-mloongson-mmi"] } {
  45. + verbose -log "Found -mloonson-mmi"
  46. + if { ![check_mips_loongson_mmi_hw_available] } {
  47. + verbose -log "No MMI avail"
  48. + return "-mloonson-mmi"
  49. + }
  50. + }
  51. +
  52. foreach { option code } [array get mips_option_tests] {
  53. +
  54. if { [mips_have_test_option_p status $option] } {
  55. regsub -all "\n" $code "\\n\\\n" asm
  56. # Use check_runtime from target-supports.exp, which caches
  57. diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
  58. index 9d79b9402e9..e0e5cbb1af8 100644
  59. --- a/gcc/testsuite/lib/gcc-dg.exp
  60. +++ b/gcc/testsuite/lib/gcc-dg.exp
  61. @@ -240,9 +240,20 @@ proc schedule-cleanups { opts } {
  62. proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
  63. # Set up the compiler flags, based on what we're going to do.
  64. + global do-what-limit
  65. set options [list]
  66. + if [info exists do-what-limit] then {
  67. + # Demote run tests to $do-what-limit if set
  68. + switch $do_what {
  69. + run {
  70. + set do_what $do-what-limit
  71. + set dg-do-what $do-what-limit
  72. + }
  73. + }
  74. + }
  75. +
  76. switch $do_what {
  77. "preprocess" {
  78. set compile_type "preprocess"
  79. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
  80. index 40f71e9ed8b..10e267fa16d 100644
  81. --- a/gcc/testsuite/lib/target-supports.exp
  82. +++ b/gcc/testsuite/lib/target-supports.exp
  83. @@ -2155,14 +2155,7 @@ proc check_mips_loongson_mmi_hw_available { } {
  84. if { !([istarget mips*-*-*]) } {
  85. expr 0
  86. } else {
  87. - check_runtime_nocache mips_loongson_mmi_hw_available {
  88. - #include <loongson-mmiintrin.h>
  89. - int main()
  90. - {
  91. - asm volatile ("paddw $f2,$f4,$f6");
  92. - return 0;
  93. - }
  94. - } "-mloongson-mmi"
  95. + expr 0
  96. }
  97. }]
  98. }
  99. @@ -2176,29 +2169,7 @@ proc check_mips_msa_hw_available { } {
  100. if { !([istarget mips*-*-*]) } {
  101. expr 0
  102. } else {
  103. - check_runtime_nocache mips_msa_hw_available {
  104. - #if !defined(__mips_msa)
  105. - #error "MSA NOT AVAIL"
  106. - #else
  107. - #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
  108. - #error "MSA NOT AVAIL FOR ISA REV < 2"
  109. - #endif
  110. - #if !defined(__mips_hard_float)
  111. - #error "MSA HARD_FLOAT REQUIRED"
  112. - #endif
  113. - #if __mips_fpr != 64
  114. - #error "MSA 64-bit FPR REQUIRED"
  115. - #endif
  116. - #include <msa.h>
  117. -
  118. - int main()
  119. - {
  120. - v8i16 v = __builtin_msa_ldi_h (0);
  121. - v[0] = 0;
  122. - return v[0];
  123. - }
  124. - #endif
  125. - } "-mmsa"
  126. + expr 0
  127. }
  128. }]
  129. }
  130. @@ -9187,6 +9158,7 @@ proc is-effective-target-keyword { arg } {
  131. proc et-dg-runtest { runtest testcases flags default-extra-flags } {
  132. global dg-do-what-default
  133. + global do-what-limit
  134. global EFFECTIVE_TARGETS
  135. global et_index
  136. @@ -9194,6 +9166,7 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
  137. foreach target $EFFECTIVE_TARGETS {
  138. set target_flags $flags
  139. set dg-do-what-default compile
  140. + set do-what-limit link
  141. set et_index [lsearch -exact $EFFECTIVE_TARGETS $target]
  142. if { [info procs add_options_for_${target}] != [list] } {
  143. set target_flags [add_options_for_${target} "$flags"]
  144. @@ -9201,8 +9174,10 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
  145. if { [info procs check_effective_target_${target}_runtime]
  146. != [list] && [check_effective_target_${target}_runtime] } {
  147. set dg-do-what-default run
  148. + set do-what-limit run
  149. }
  150. $runtest $testcases $target_flags ${default-extra-flags}
  151. + unset do-what-limit
  152. }
  153. } else {
  154. set et_index 0
  155. @@ -10789,6 +10764,7 @@ proc check_effective_target_sigsetjmp {} {
  156. proc check_vect_support_and_set_flags { } {
  157. global DEFAULT_VECTCFLAGS
  158. global dg-do-what-default
  159. + global do-what-limit
  160. global EFFECTIVE_TARGETS
  161. if [istarget powerpc-*paired*] {
  162. @@ -10797,6 +10773,7 @@ proc check_vect_support_and_set_flags { } {
  163. set dg-do-what-default run
  164. } else {
  165. set dg-do-what-default compile
  166. + set do-what-limit link
  167. }
  168. } elseif [istarget powerpc*-*-*] {
  169. # Skip targets not supporting -maltivec.
  170. @@ -10821,6 +10798,7 @@ proc check_vect_support_and_set_flags { } {
  171. lappend DEFAULT_VECTCFLAGS "-mcpu=970"
  172. }
  173. set dg-do-what-default compile
  174. + set do-what-limit link
  175. }
  176. } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
  177. lappend DEFAULT_VECTCFLAGS "-msse2"
  178. @@ -10828,6 +10806,7 @@ proc check_vect_support_and_set_flags { } {
  179. set dg-do-what-default run
  180. } else {
  181. set dg-do-what-default compile
  182. + set do-what-limit link
  183. }
  184. } elseif { [istarget mips*-*-*]
  185. && [check_effective_target_nomips16] } {
  186. @@ -10847,6 +10826,7 @@ proc check_vect_support_and_set_flags { } {
  187. set dg-do-what-default run
  188. } else {
  189. set dg-do-what-default compile
  190. + set do-what-limit link
  191. }
  192. } elseif [istarget alpha*-*-*] {
  193. # Alpha's vectorization capabilities are extremely limited.
  194. @@ -10860,6 +10840,7 @@ proc check_vect_support_and_set_flags { } {
  195. set dg-do-what-default run
  196. } else {
  197. set dg-do-what-default compile
  198. + set do-what-limit link
  199. }
  200. } elseif [istarget ia64-*-*] {
  201. set dg-do-what-default run
  202. @@ -10873,6 +10854,7 @@ proc check_vect_support_and_set_flags { } {
  203. set dg-do-what-default run
  204. } else {
  205. set dg-do-what-default compile
  206. + set do-what-limit link
  207. }
  208. } elseif [istarget aarch64*-*-*] {
  209. set dg-do-what-default run
  210. @@ -10897,6 +10879,7 @@ proc check_vect_support_and_set_flags { } {
  211. } else {
  212. lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch"
  213. set dg-do-what-default compile
  214. + set do-what-limit link
  215. }
  216. } elseif [istarget amdgcn-*-*] {
  217. set dg-do-what-default run