From 5bac1edb4f4c4fc55b90d7034f23c3f4dbec98c0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 8 Dec 2017 01:03:28 +0100 Subject: [PATCH] re PR target/83252 (Wrong code with "-march=skylake-avx512 -O3") PR target/83252 * gcc.target/i386/i386.exp (check_effective_target_bmi2): Moved to ... * lib/target-supports.exp (check_effective_target_bmi2): ... here. Guard with i?86-*-* x86_64-*-*. * g++.dg/opt/pr83252.C: New test. From-SVN: r255487 --- gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/g++.dg/opt/pr83252.C | 92 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/i386.exp | 11 --- gcc/testsuite/lib/target-supports.exp | 14 ++++ 4 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr83252.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d12ca43c7a1..564a301e700 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2017-12-08 Jakub Jelinek + PR target/83252 + * gcc.target/i386/i386.exp (check_effective_target_bmi2): Moved to ... + * lib/target-supports.exp (check_effective_target_bmi2): ... here. Guard with + i?86-*-* x86_64-*-*. + * g++.dg/opt/pr83252.C: New test. + PR target/81906 * gcc.target/i386/pr81906.c: New test. diff --git a/gcc/testsuite/g++.dg/opt/pr83252.C b/gcc/testsuite/g++.dg/opt/pr83252.C new file mode 100644 index 00000000000..835b77fd18c --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr83252.C @@ -0,0 +1,92 @@ +// PR target/83252 +// { dg-do run } +// { dg-options "-O3" } +// { dg-additional-options "-mbmi2 -mtune=intel" { target bmi2 } } + +#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8 && __CHAR_BIT__ == 8 + +#ifdef __BMI2__ +#include "../../gcc.target/i386/bmi2-check.h" +#endif + +long long h = 707493562598231894LL, i, n, x3, x5; +long long j, l = -2228108721620697360LL, o, y9; +int k, p, r, s, t = 2, u, w, z8, x7, y4, y5, y6, y7, y8, x1, x2, x4, x6, d; +unsigned v, x = 751359462, z = 1, y3 = 60; +unsigned *y = &x, *z2 = &z, *z3 = &v; +unsigned long long z1 = 2; +unsigned long long *z4 = &z1; +long long *z7; +unsigned long long z9 = 7091529791657LL; + +void +foo () +{ + if ((-2783342978U * (int) l || z) && z2 && h && z1 && z9 & ~-(-2783342978U * (int) l)) + { + i = 3060393125LL < n; + y7 = o >> *y - 751359400; + *z3 = x7; + long a = (o >> *y - 751359400 >> ~-(-2783342978U * (int) l) - 88480234) - (-2783342978U * (int) l); + y6 = a; + if (~0 % *z4 % 5) + y8 = -3 * (l - 4 ? : 407228174574); + if (y3 < 1) + { + long long *b = &y9; + z3 = 0; + int c = *z2; + *z7 = 0; + x1 = ~(-((unsigned) (-2783342978U * (unsigned long long) l))); + p = *b & j; + x2 = c; + } + else + { + j = 0; + int e = !0 % (7 % *z4); + r = ((s || !k) && t) - -(-2783342978U * (unsigned long long) l); + x3 = o >> *y - 751359400; + y9 = z9; + long f = o >> *y - 751359400 >> ~-(-2783342978U * (int) l) - 88480234; + x4 = z1; + u = n * f * e * y4; + } + if (8ULL * -(-(-2783342978U * (int) l))) + ; + else + { + *z3 = 0; + int g = 3 & y5; + x5 = (unsigned) (~o + 9223372036854775807 >> l); + z8 = g + y9; + v = j || ~0 + 9223372036854775807 >> ~-(-2783342978U * (int) l); + x6 = o >> (8 * l); + w = *y ? -2783342978U * l : 0; + } + } +} + +#ifdef __BMI2__ +void +bmi2_test (void) +{ + foo (); + if (r != 88480289) + __builtin_abort (); +} +#else +int +main () +{ + foo (); + if (r != 88480289) + __builtin_abort (); +} +#endif +#else +int +main () +{ +} +#endif diff --git a/gcc/testsuite/gcc.target/i386/i386.exp b/gcc/testsuite/gcc.target/i386/i386.exp index b4468131d0d..c663a12bcb3 100644 --- a/gcc/testsuite/gcc.target/i386/i386.exp +++ b/gcc/testsuite/gcc.target/i386/i386.exp @@ -207,17 +207,6 @@ proc check_effective_target_bmi { } { } "-mbmi" ] } -# Return 1 if bmi2 instructions can be compiled. -proc check_effective_target_bmi2 { } { - return [check_no_compiler_messages bmi2 object { - unsigned int - _bzhi_u32 (unsigned int __X, unsigned int __Y) - { - return __builtin_ia32_bzhi_si (__X, __Y); - } - } "-mbmi2" ] -} - # Return 1 if ADX instructions can be compiled. proc check_effective_target_adx { } { return [check_no_compiler_messages adx object { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index ed7d624873c..ff8c8050652 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1856,6 +1856,20 @@ proc check_effective_target_avx512f_runtime { } { return 0 } +# Return 1 if bmi2 instructions can be compiled. +proc check_effective_target_bmi2 { } { + if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { + return 0 + } + return [check_no_compiler_messages bmi2 object { + unsigned int + _bzhi_u32 (unsigned int __X, unsigned int __Y) + { + return __builtin_ia32_bzhi_si (__X, __Y); + } + } "-mbmi2" ] +} + # Return 1 if the target supports executing MIPS Paired-Single instructions, # 0 otherwise. Cache the result. -- 2.30.2