From 12a813c16f5c7c5a10d8d5080b315463c4c584f8 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Wed, 28 Sep 2016 23:29:47 +0200 Subject: [PATCH] re PR target/77756 (__get_cpuid() returns wrong values for level 7 (extended features)) PR target/77756 * config/i386/cpuid.h (__get_cpuid): Handle CPUID level >= 7. testsuite/ChangeLog: PR target/77756 * gcc.target/i386/pr77756.c: New test. From-SVN: r240597 --- gcc/ChangeLog | 63 +++++++++++-------------- gcc/config/i386/cpuid.h | 12 ++++- gcc/testsuite/ChangeLog | 51 +++++++++----------- gcc/testsuite/gcc.target/i386/pr77756.c | 22 +++++++++ 4 files changed, 81 insertions(+), 67 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr77756.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5de30f8748f..4a531197713 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-09-28 Uros Bizjak + + PR target/77756 + * config/i386/cpuid.h (__get_cpuid): Handle CPUID level >= 7. + 2016-09-28 Jakub Jelinek * gimple-ssa-sprintf.c: Fix comment formatting. @@ -248,8 +253,8 @@ 2016-09-26 Kugan Vivekanandarajah PR middle-end/77719 - * tree-ssa-reassoc.c (make_new_ssa_for_def): Use gimple_get_lhs to get lhs - instead of gimple_assign_lhs as stmt can be builtins too. + * tree-ssa-reassoc.c (make_new_ssa_for_def): Use gimple_get_lhs + to get lhs instead of gimple_assign_lhs as stmt can be builtins too. 2016-09-26 Thomas Preud'homme @@ -314,7 +319,7 @@ * tsan.c (instrument_memory_accesses): Likewise. 2016-09-26 Kyrylo Tkachov - Alexander Monakov + Alexander Monakov * regrename.c (rename_chains): Check HARD_FRAME_POINTER_IS_FRAME_POINTER rather than @@ -333,10 +338,8 @@ 2016-09-26 Martin Liska PR gcov-profile/23332 - * profile.c (instrument_values): Do not handle - HIST_TYPE_CONST_DELTA. - * tree-profile.c (gimple_gen_const_delta_profiler): - Remove. + * profile.c (instrument_values): Do not handle HIST_TYPE_CONST_DELTA. + * tree-profile.c (gimple_gen_const_delta_profiler): Remove. * value-prof.c (dump_histogram_value): Do not handle HIST_TYPE_CONST_DELTA. (stream_in_histogram_value): Likewise. @@ -360,8 +363,7 @@ 2016-09-26 Andre Vieira - * target.def(elf_flags_numeric): Change documentation to - present tense. + * target.def(elf_flags_numeric): Change documentation to present tense. * doc/tm.texi: Regenerate. 2016-09-26 Marek Polacek @@ -906,13 +908,13 @@ 2016-09-23 Dominik Vogt - * config/s390/predicates.md ("contiguous_bitmask_operand"): Adapt to new - interface of s390_contiguous_bitmask_p. + * config/s390/predicates.md ("contiguous_bitmask_operand"): Adapt to + new interface of s390_contiguous_bitmask_p. ("contiguous_bitmask_nowrap_operand"): New predicate. - * ("*anddi3_cc", "*anddi3_cconly", "*anddi3"): Replace NxxDq with NxxDw. + ("*anddi3_cc", "*anddi3_cconly", "*anddi3"): Replace NxxDq with NxxDw. * config/s390/constraints.md ("NxxDw", "NxxSq"): Adapt to new interface of s390_contiguous_bitmask_p. - * ("NxxDw"): Rename NxxDq constraint to NxxDw. + ("NxxDw"): Rename NxxDq constraint to NxxDw. ("NxxSw"): New constraint. * config/s390/s390.md ("*andsi3_zarch"): Enable bitmask wraparound. * config/s390/s390-protos.h (s390_contiguous_bitmask_p): Updated @@ -1023,8 +1025,7 @@ 2016-09-23 Jakub Jelinek - * ipa-cp.c (ipcp_store_vr_results): Avoid static local - var zero. + * ipa-cp.c (ipcp_store_vr_results): Avoid static local var zero. * sreal.h (sreal::min, sreal::max): Avoid static local vars, construct values without normalization. * tree-ssa-sccvn.c (vn_reference_lookup_3): Don't initialize @@ -1051,8 +1052,7 @@ (*arm_movhi_fp16): New. (*thumb2_movhi_fp16): New. (*movhf_vfp_fp16): New. - (*movhf_vfp_neon): Disable when VFP FP16 instructions are - available. + (*movhf_vfp_neon): Disable when VFP FP16 instructions are available. (*movhf_vfp): Likewise. (extendhfsf2): Enable when VFP FP16 instructions are available. (truncsfhf2): Enable when VFP FP16 instructions are available. @@ -1108,8 +1108,7 @@ 2016-09-23 Jiong Wang Matthew Wahab - * config/arm/arm.c (output_move_vfp): Weaken assert to allow - HImode. + * config/arm/arm.c (output_move_vfp): Weaken assert to allow HImode. (arm_hard_regno_mode_ok): Allow HImode values in VFP registers. * config/arm/arm.md (*movhi_bytes): Disable when VFP registers are available. Also fix some white-space. @@ -1138,8 +1137,7 @@ 2016-09-23 Martin Liska - * ipa-icf.c (sem_variable::merge): Replace adress - with address. + * ipa-icf.c (sem_variable::merge): Replace adress with address. 2016-09-23 Matthew Wahab @@ -1167,8 +1165,7 @@ 2016-09-23 Martin Liska - * doc/extend.texi: Remove fused-madd from i386 target - options. + * doc/extend.texi: Remove fused-madd from i386 target options. 2016-09-23 Martin Liska @@ -1260,8 +1257,7 @@ 2016-09-22 Trevor Saunders - * emit-rtl.c (next_active_insn): Change argument type to - rtx_insn *. + * emit-rtl.c (next_active_insn): Change argument type to rtx_insn *. (prev_active_insn): Likewise. (active_insn_p): Likewise. * rtl.h: Adjust prototypes. @@ -1297,8 +1293,7 @@ 2016-09-22 Trevor Saunders - * emit-rtl.c (next_nondebug_insn): Change argument type to - rtx_insn *. + * emit-rtl.c (next_nondebug_insn): Change argument type to rtx_insn *. (prev_nondebug_insn): Likewise. * loop-doloop.c (doloop_condition_get): Likewise. * rtl.h: Adjust prototype. @@ -1306,8 +1301,7 @@ 2016-09-22 Trevor Saunders - * emit-rtl.c (next_nonnote_insn): Change argument type to - rtx_insn *. + * emit-rtl.c (next_nonnote_insn): Change argument type to rtx_insn *. (prev_nonnote_insn): Likewise. * jump.c (reversed_comparison_code_parts): Likewise. (reversed_comparison): Likewise. @@ -1343,8 +1337,7 @@ * config/m32r/m32r.c (m32r_expand_epilogue): Likewise. * config/nds32/nds32-protos.h (nds32_target_alignment): Likewise. * config/nds32/nds32.c (nds32_target_alignment): Likewise. - * config/rl78/rl78.c (rl78_alloc_physical_registers_op2): - * Likewise. + * config/rl78/rl78.c (rl78_alloc_physical_registers_op2): Likewise. (rl78_alloc_physical_registers_cmp): Likewise. (rl78_alloc_physical_registers_umul): Likewise. (rl78_calculate_death_notes): Likewise. @@ -1527,7 +1520,7 @@ (handle_pure_call): Likewise. 2016-09-21 Richard Biener - Jakub Jelinek + Jakub Jelinek PR tree-optimization/77621 * tree-vect-data-refs.c (vect_analyze_data_ref_accesses): Split @@ -1569,8 +1562,7 @@ 2016-09-21 Kugan Vivekanandarajah - * tree-vrp.c (get_value_range): Teach PARM_DECL to use ipa-vrp - results. + * tree-vrp.c (get_value_range): Teach PARM_DECL to use ipa-vrp results. 2016-09-21 Kugan Vivekanandarajah @@ -1632,8 +1624,7 @@ (evrp_dom_walker::push_value_range): Likewise. (evrp_dom_walker::pop_value_range): Likewise. (execute_early_vrp): Likewise. - (execute_vrp): Call vrp_initialize_lattice and - vrp_free_lattice. + (execute_vrp): Call vrp_initialize_lattice and vrp_free_lattice. (make_pass_early_vrp): New. 2016-09-20 Uros Bizjak diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index 8760e60d382..a4f658af797 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -244,6 +244,16 @@ __get_cpuid (unsigned int __level, if (__get_cpuid_max (__ext, 0) < __level) return 0; - __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx); + if (__ext) + __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx); + else + { + if (__level >= 13) + __cpuid_count (__level, 1, *__eax, *__ebx, *__ecx, *__edx); + else if (__level >= 7) + __cpuid_count (__level, 0, *__eax, *__ebx, *__ecx, *__edx); + else + __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx); + } return 1; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca1ded4b17b..f3ab8e8bc38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-09-28 Uros Bizjak + + PR target/77756 + * gcc.target/i386/pr77756.c: New test. + 2016-09-28 Martin Sebor PR middle-end/77721 @@ -115,7 +120,7 @@ 2016-09-26 Thomas Preud'homme * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust regex to accept - singular form of byte when quantity is unknown. + singular form of byte when quantity is unknown. 2016-09-26 Marek Polacek @@ -169,7 +174,7 @@ 2016-09-25 Steven G. Kargl - PR fortran/77429 + PR fortran/77429 * gfortran.dg/pr77429.f90: New test. 2016-09-25 Steven G. Kargl @@ -339,38 +344,24 @@ tests, enabled if macro __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is defined. * gcc.target/aarch64/advsimd-intrinsics/vmul_lane.c: Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vmul_n.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vneg.c: - Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vmul_n.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vneg.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vpXXX.inc: Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vpadd.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vpmax.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vpmin.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrecpe.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrecps.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrnd.c: - Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vpadd.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vpmax.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vpmin.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrecpe.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrecps.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrnd.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vrndX.inc: Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrnda.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndm.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndn.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndp.c: - Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndx.c: - Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrnda.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndm.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndn.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndp.c: Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vrndx.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vrsqrte.c: Likewise. * gcc.target/aarch64/advsimd-intrinsics/vrsqrts.c: Likewise. - * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vsub.c: - Likewise. + * gcc.target/gcc.target/aarch64/advsimd-intrinsics/vsub.c: Likewise. 2016-09-23 Jiong Wang Matthew Wahab diff --git a/gcc/testsuite/gcc.target/i386/pr77756.c b/gcc/testsuite/gcc.target/i386/pr77756.c new file mode 100644 index 00000000000..cd880381006 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr77756.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +#include "cpuid.h" + +int +main () +{ + __builtin_cpu_init (); + + if (__builtin_cpu_supports ("avx2")) + { + unsigned int eax, ebx, ecx, edx; + + if (!__get_cpuid (7, &eax, &ebx, &ecx, &edx)) + __builtin_abort (); + + if (!(ebx & bit_AVX2)) + __builtin_abort (); + } + + return 0; +} -- 2.30.2