On Wed, Nov 29, 2017 at 05:21:22PM -0500, Vladimir Makarov wrote: > The following patch fixes > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80818 > > The patch was successfully tested and bootstrapped on x86_64. The patch > has no test because it is hard to check the problem. I checked manually
This changed fixed PR83252 which has a reasonably small testcase. I've further reduced it using creduce (with -O0 -W{,maybe-}uninitialized and/or -fsanitize=undefined checking, plus test that it succeeds with r255258 and fails with r255257). Can you please double check if the testcase represents the same issue you were working on or if your change merely made the bug latent again? 2017-12-04 Jakub Jelinek <ja...@redhat.com> 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. --- gcc/testsuite/gcc.target/i386/i386.exp.jj 2017-11-24 08:58:04.000000000 +0100 +++ gcc/testsuite/gcc.target/i386/i386.exp 2017-12-04 11:42:49.215754513 +0100 @@ -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 { --- gcc/testsuite/lib/target-supports.exp.jj 2017-11-28 12:11:35.000000000 +0100 +++ gcc/testsuite/lib/target-supports.exp 2017-12-04 11:34:55.080598710 +0100 @@ -1852,6 +1852,20 @@ proc check_effective_target_avx512f_runt 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. --- gcc/testsuite/g++.dg/opt/pr83252.C.jj 2017-12-04 11:31:29.945191880 +0100 +++ gcc/testsuite/g++.dg/opt/pr83252.C 2017-12-04 11:41:33.041686570 +0100 @@ -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 Jakub