Blame SOURCES/gcc48-rh1304449.patch

8178f7
2015-12-24  Kirill Yukhin  <kirill.yukhin@intel.com>
8178f7
8178f7
	* common/config/i386/i386-common.c (OPTION_MASK_ISA_PKU_SET): New.
8178f7
	(OPTION_MASK_ISA_PKU_UNSET): Ditto.
8178f7
	(ix86_handle_option): Handle OPT_mpku.
8178f7
	* config.gcc: Add pkuintrin.h to i[34567]86-*-* and x86_64-*-*
8178f7
	targets.
8178f7
	* config/i386/cpuid.h (host_detect_local_cpu): Detect PKU feature.
8178f7
	* config/i386/i386-c.c (ix86_target_macros_internal): Handle PKU ISA
8178f7
	flag.
8178f7
	* config/i386/i386.c (ix86_target_string): Add "-mpku" to
8178f7
	ix86_target_opts.
8178f7
	(ix86_option_override_internal): Define PTA_PKU, mention new key
8178f7
	in skylake-avx512. Handle new ISA bits.
8178f7
	(ix86_valid_target_attribute_inner_p): Add "pku".
8178f7
	(enum ix86_builtins): Add IX86_BUILTIN_RDPKRU and IX86_BUILTIN_WRPKRU.
8178f7
	(builtin_description bdesc_special_args[]): Add new built-ins.
8178f7
	* config/i386/i386.h (define TARGET_PKU): New.
8178f7
	(define TARGET_PKU_P): Ditto.
8178f7
	* config/i386/i386.md (define_c_enum "unspecv"): Add UNSPEC_PKU.
8178f7
	(define_expand "rdpkru"): New.
8178f7
	(define_insn "*rdpkru"): Ditto.
8178f7
	(define_expand "wrpkru"): Ditto.
8178f7
	(define_insn "*wrpkru"): Ditto.
8178f7
	* config/i386/i386.opt (mpku): Ditto.
8178f7
	* config/i386/pkuintrin.h: New file.
8178f7
	* config/i386/x86intrin.h: Include pkuintrin.h
8178f7
	* doc/extend.texi: Describe new built-ins.
8178f7
	* doc/invoke.texi: Describe new switches.
8178f7
8178f7
	* g++.dg/other/i386-2.C: Add -mpku.
8178f7
	* g++.dg/other/i386-3.C: Ditto.
8178f7
	* gcc.target/i386/rdpku-1.c: New test.
8178f7
	* gcc.target/i386/sse-12.c: Add -mpku.
8178f7
	* gcc.target/i386/sse-13.c: Ditto.
8178f7
	* gcc.target/i386/sse-22.c: Ditto.
8178f7
	* gcc.target/i386/sse-33.c: Ditto.
8178f7
	* gcc.target/i386/wrpku-1.c: New test.
8178f7
8178f7
--- gcc/config.gcc	(revision 231943)
8178f7
+++ gcc/config.gcc	(revision 231945)
8178f7
@@ -368,7 +368,7 @@ i[34567]86-*-*)
8178f7
 		       lzcntintrin.h bmiintrin.h bmi2intrin.h tbmintrin.h
8178f7
 		       avx2intrin.h fmaintrin.h f16cintrin.h rtmintrin.h
8178f7
 		       xtestintrin.h rdseedintrin.h prfchwintrin.h adxintrin.h
8178f7
-		       fxsrintrin.h xsaveintrin.h xsaveoptintrin.h"
8178f7
+		       fxsrintrin.h xsaveintrin.h xsaveoptintrin.h pkuintrin.h"
8178f7
 	;;
8178f7
 x86_64-*-*)
8178f7
 	cpu_type=i386
8178f7
@@ -383,7 +383,7 @@ x86_64-*-*)
8178f7
 		       lzcntintrin.h bmiintrin.h tbmintrin.h bmi2intrin.h
8178f7
 		       avx2intrin.h fmaintrin.h f16cintrin.h rtmintrin.h
8178f7
 		       xtestintrin.h rdseedintrin.h prfchwintrin.h adxintrin.h
8178f7
-		       fxsrintrin.h xsaveintrin.h xsaveoptintrin.h"
8178f7
+		       fxsrintrin.h xsaveintrin.h xsaveoptintrin.h pkuintrin.h"
8178f7
 	need_64bit_hwint=yes
8178f7
 	;;
8178f7
 ia64-*-*)
8178f7
--- gcc/common/config/i386/i386-common.c	(revision 231943)
8178f7
+++ gcc/common/config/i386/i386-common.c	(revision 231945)
8178f7
@@ -98,6 +98,7 @@ along with GCC; see the file COPYING3.
8178f7
 #define OPTION_MASK_ISA_RDRND_SET OPTION_MASK_ISA_RDRND
8178f7
 #define OPTION_MASK_ISA_F16C_SET \
8178f7
   (OPTION_MASK_ISA_F16C | OPTION_MASK_ISA_AVX_SET)
8178f7
+#define OPTION_MASK_ISA_PKU_SET OPTION_MASK_ISA_PKU
8178f7
 
8178f7
 /* Define a set of ISAs which aren't available when a given ISA is
8178f7
    disabled.  MMX and SSE ISAs are handled separately.  */
8178f7
@@ -164,6 +165,7 @@ along with GCC; see the file COPYING3.
8178f7
 #define OPTION_MASK_ISA_FSGSBASE_UNSET OPTION_MASK_ISA_FSGSBASE
8178f7
 #define OPTION_MASK_ISA_RDRND_UNSET OPTION_MASK_ISA_RDRND
8178f7
 #define OPTION_MASK_ISA_F16C_UNSET OPTION_MASK_ISA_F16C
8178f7
+#define OPTION_MASK_ISA_PKU_UNSET OPTION_MASK_ISA_PKU
8178f7
 
8178f7
 /* Implement TARGET_HANDLE_OPTION.  */
8178f7
 
8178f7
@@ -659,6 +661,19 @@ ix86_handle_option (struct gcc_options *
8178f7
 	}
8178f7
       return true;
8178f7
 
8178f7
+    case OPT_mpku:
8178f7
+      if (value)
8178f7
+	{
8178f7
+	  opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PKU_SET;
8178f7
+	  opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_PKU_SET;
8178f7
+	}
8178f7
+      else
8178f7
+	{
8178f7
+	  opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_PKU_UNSET;
8178f7
+	  opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_PKU_UNSET;
8178f7
+	}
8178f7
+      return true;
8178f7
+
8178f7
   /* Comes from final.c -- no real reason to change it.  */
8178f7
 #define MAX_CODE_ALIGN 16
8178f7
 
8178f7
--- gcc/config/i386/i386.h	(revision 231943)
8178f7
+++ gcc/config/i386/i386.h	(revision 231945)
8178f7
@@ -80,6 +80,7 @@ see the files COPYING3 and COPYING.RUNTI
8178f7
 #define TARGET_FXSR	TARGET_ISA_FXSR
8178f7
 #define TARGET_XSAVE	TARGET_ISA_XSAVE
8178f7
 #define TARGET_XSAVEOPT	TARGET_ISA_XSAVEOPT
8178f7
+#define TARGET_PKU	TARGET_ISA_PKU
8178f7
 
8178f7
 #define TARGET_LP64	TARGET_ABI_64
8178f7
 #define TARGET_X32	TARGET_ABI_X32
8178f7
--- gcc/config/i386/i386.md	(revision 231943)
8178f7
+++ gcc/config/i386/i386.md	(revision 231945)
8178f7
@@ -224,6 +224,9 @@ (define_c_enum "unspecv" [
8178f7
   UNSPECV_XTEST
8178f7
 
8178f7
   UNSPECV_NLGR
8178f7
+
8178f7
+  ;; For RDPKRU and WRPKRU support
8178f7
+  UNSPECV_PKU
8178f7
 ])
8178f7
 
8178f7
 ;; Constants to represent rounding modes in the ROUND instruction
8178f7
@@ -18289,6 +18292,48 @@ (define_insn "xtest_1"
8178f7
   [(set_attr "type" "other")
8178f7
    (set_attr "length" "3")])
8178f7
 
8178f7
+;; RDPKRU and WRPKRU
8178f7
+
8178f7
+(define_expand "rdpkru"
8178f7
+  [(parallel
8178f7
+     [(set (match_operand:SI 0 "register_operand")
8178f7
+	   (unspec_volatile:SI [(match_dup 1)] UNSPECV_PKU))
8178f7
+      (set (match_dup 2) (const_int 0))])]
8178f7
+  "TARGET_PKU"
8178f7
+{
8178f7
+  operands[1] = force_reg (SImode, const0_rtx);
8178f7
+  operands[2] = gen_reg_rtx (SImode);
8178f7
+})
8178f7
+
8178f7
+(define_insn "*rdpkru"
8178f7
+  [(set (match_operand:SI 0 "register_operand" "=a")
8178f7
+	(unspec_volatile:SI [(match_operand:SI 2 "register_operand" "c")]
8178f7
+			    UNSPECV_PKU))
8178f7
+   (set (match_operand:SI 1 "register_operand" "=d")
8178f7
+	(const_int 0))]
8178f7
+  "TARGET_PKU"
8178f7
+  "rdpkru"
8178f7
+  [(set_attr "type" "other")])
8178f7
+
8178f7
+(define_expand "wrpkru"
8178f7
+  [(unspec_volatile:SI
8178f7
+     [(match_operand:SI 0 "register_operand")
8178f7
+      (match_dup 1) (match_dup 2)] UNSPECV_PKU)]
8178f7
+  "TARGET_PKU"
8178f7
+{
8178f7
+  operands[1] = force_reg (SImode, const0_rtx);
8178f7
+  operands[2] = force_reg (SImode, const0_rtx);
8178f7
+})
8178f7
+
8178f7
+(define_insn "*wrpkru"
8178f7
+  [(unspec_volatile:SI
8178f7
+     [(match_operand:SI 0 "register_operand" "a")
8178f7
+      (match_operand:SI 1 "register_operand" "d")
8178f7
+      (match_operand:SI 2 "register_operand" "c")] UNSPECV_PKU)]
8178f7
+  "TARGET_PKU"
8178f7
+  "wrpkru"
8178f7
+  [(set_attr "type" "other")])
8178f7
+
8178f7
 (include "mmx.md")
8178f7
 (include "sse.md")
8178f7
 (include "sync.md")
8178f7
--- gcc/config/i386/pkuintrin.h	(revision 0)
8178f7
+++ gcc/config/i386/pkuintrin.h	(revision 231945)
8178f7
@@ -0,0 +1,45 @@
8178f7
+/* Copyright (C) 2015 Free Software Foundation, Inc.
8178f7
+
8178f7
+   This file is part of GCC.
8178f7
+
8178f7
+   GCC is free software; you can redistribute it and/or modify
8178f7
+   it under the terms of the GNU General Public License as published by
8178f7
+   the Free Software Foundation; either version 3, or (at your option)
8178f7
+   any later version.
8178f7
+
8178f7
+   GCC is distributed in the hope that it will be useful,
8178f7
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
8178f7
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8178f7
+   GNU General Public License for more details.
8178f7
+
8178f7
+   Under Section 7 of GPL version 3, you are granted additional
8178f7
+   permissions described in the GCC Runtime Library Exception, version
8178f7
+   3.1, as published by the Free Software Foundation.
8178f7
+
8178f7
+   You should have received a copy of the GNU General Public License and
8178f7
+   a copy of the GCC Runtime Library Exception along with this program;
8178f7
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
8178f7
+   <http://www.gnu.org/licenses/>.  */
8178f7
+
8178f7
+#if !defined _X86INTRIN_H_INCLUDED
8178f7
+# error "Never use <pkuintrin.h> directly; include <x86intrin.h> instead."
8178f7
+#endif
8178f7
+
8178f7
+#ifndef _PKUINTRIN_H_INCLUDED
8178f7
+#define _PKUINTRIN_H_INCLUDED
8178f7
+
8178f7
+extern __inline unsigned int
8178f7
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
8178f7
+_rdpkru_u32(void)
8178f7
+{
8178f7
+  return __builtin_ia32_rdpkru ();
8178f7
+}
8178f7
+
8178f7
+extern __inline void
8178f7
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
8178f7
+_wrpkru(unsigned int key)
8178f7
+{
8178f7
+  return __builtin_ia32_wrpkru (key);
8178f7
+}
8178f7
+
8178f7
+#endif /* _PKUINTRIN_H_INCLUDED */
8178f7
--- gcc/config/i386/cpuid.h	(revision 231943)
8178f7
+++ gcc/config/i386/cpuid.h	(revision 231945)
8178f7
@@ -74,6 +74,10 @@
8178f7
 #define bit_RDSEED	(1 << 18)
8178f7
 #define bit_ADX	(1 << 19)
8178f7
 
8178f7
+/* %ecx */
8178f7
+#define bit_PKU	(1 << 3)
8178f7
+#define bit_OSPKE	(1 << 4)
8178f7
+ 
8178f7
 /* Extended State Enumeration Sub-leaf (%eax == 13, %ecx == 1) */
8178f7
 #define bit_XSAVEOPT	(1 << 0)
8178f7
 
8178f7
--- gcc/config/i386/x86intrin.h	(revision 231943)
8178f7
+++ gcc/config/i386/x86intrin.h	(revision 231945)
8178f7
@@ -119,4 +119,8 @@
8178f7
 
8178f7
 #include <adxintrin.h>
8178f7
 
8178f7
+#ifdef __PKU__
8178f7
+#include <pkuintrin.h>
8178f7
+#endif
8178f7
+
8178f7
 #endif /* _X86INTRIN_H_INCLUDED */
8178f7
--- gcc/config/i386/i386-c.c	(revision 231943)
8178f7
+++ gcc/config/i386/i386-c.c	(revision 231945)
8178f7
@@ -348,6 +348,8 @@ ix86_target_macros_internal (HOST_WIDE_I
8178f7
     def_or_undef (parse_in, "__XSAVE__");
8178f7
   if (isa_flag & OPTION_MASK_ISA_XSAVEOPT)
8178f7
     def_or_undef (parse_in, "__XSAVEOPT__");
8178f7
+  if (isa_flag & OPTION_MASK_ISA_PKU)
8178f7
+    def_or_undef (parse_in, "__PKU__");
8178f7
   if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE))
8178f7
     def_or_undef (parse_in, "__SSE_MATH__");
8178f7
   if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2))
8178f7
--- gcc/config/i386/i386.opt	(revision 231943)
8178f7
+++ gcc/config/i386/i386.opt	(revision 231945)
8178f7
@@ -626,3 +626,7 @@ Split 32-byte AVX unaligned store
8178f7
 mrtm
8178f7
 Target Report Mask(ISA_RTM) Var(ix86_isa_flags) Save
8178f7
 Support RTM built-in functions and code generation
8178f7
+
8178f7
+mpku
8178f7
+Target Report Mask(ISA_PKU) Var(ix86_isa_flags) Save
8178f7
+Support PKU built-in functions and code generation
8178f7
--- gcc/config/i386/driver-i386.c	(revision 231943)
8178f7
+++ gcc/config/i386/driver-i386.c	(revision 231945)
8178f7
@@ -408,6 +408,7 @@ const char *host_detect_local_cpu (int a
8178f7
   unsigned int has_rdrnd = 0, has_f16c = 0, has_fsgsbase = 0;
8178f7
   unsigned int has_rdseed = 0, has_prfchw = 0, has_adx = 0;
8178f7
   unsigned int has_osxsave = 0, has_fxsr = 0, has_xsave = 0, has_xsaveopt = 0;
8178f7
+  unsigned int has_pku = 0;
8178f7
 
8178f7
   bool arch;
8178f7
 
8178f7
@@ -479,6 +480,8 @@ const char *host_detect_local_cpu (int a
8178f7
       has_fsgsbase = ebx & bit_FSGSBASE;
8178f7
       has_rdseed = ebx & bit_RDSEED;
8178f7
       has_adx = ebx & bit_ADX;
8178f7
+
8178f7
+      has_pku = ecx & bit_OSPKE;
8178f7
     }
8178f7
 
8178f7
   if (max_level >= 13)
8178f7
@@ -855,12 +858,13 @@ const char *host_detect_local_cpu (int a
8178f7
       const char *fxsr = has_fxsr ? " -mfxsr" : " -mno-fxsr";
8178f7
       const char *xsave = has_xsave ? " -mxsave" : " -mno-xsave";
8178f7
       const char *xsaveopt = has_xsaveopt ? " -mxsaveopt" : " -mno-xsaveopt";
8178f7
+      const char *pku = has_pku ? " -mpku" : " -mno-pku";
8178f7
 
8178f7
       options = concat (options, cx16, sahf, movbe, ase, pclmul,
8178f7
 			popcnt, abm, lwp, fma, fma4, xop, bmi, bmi2,
8178f7
 			tbm, avx, avx2, sse4_2, sse4_1, lzcnt, rtm,
8178f7
 			hle, rdrnd, f16c, fsgsbase, rdseed, prfchw, adx,
8178f7
-			fxsr, xsave, xsaveopt, NULL);
8178f7
+			fxsr, xsave, xsaveopt, pku, NULL);
8178f7
     }
8178f7
 
8178f7
 done:
8178f7
--- gcc/config/i386/i386.c	(revision 231943)
8178f7
+++ gcc/config/i386/i386.c	(revision 231945)
8178f7
@@ -2632,6 +2632,7 @@ ix86_target_string (HOST_WIDE_INT isa, i
8178f7
     { "-mrtm",		OPTION_MASK_ISA_RTM },
8178f7
     { "-mxsave",	OPTION_MASK_ISA_XSAVE },
8178f7
     { "-mxsaveopt",	OPTION_MASK_ISA_XSAVEOPT },
8178f7
+    { "-mpku",		OPTION_MASK_ISA_PKU },
8178f7
   };
8178f7
 
8178f7
   /* Flag options.  */
8178f7
@@ -2905,6 +2906,7 @@ ix86_option_override_internal (bool main
8178f7
 #define PTA_FXSR		(HOST_WIDE_INT_1 << 37)
8178f7
 #define PTA_XSAVE		(HOST_WIDE_INT_1 << 38)
8178f7
 #define PTA_XSAVEOPT		(HOST_WIDE_INT_1 << 39)
8178f7
+#define PTA_PKU			(HOST_WIDE_INT_1 << 60)
8178f7
 
8178f7
 /* if this reaches 64, need to widen struct pta flags below */
8178f7
 
8178f7
@@ -3429,6 +3431,9 @@ ix86_option_override_internal (bool main
8178f7
 	if (processor_alias_table[i].flags & PTA_XSAVEOPT
8178f7
 	    && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_XSAVEOPT))
8178f7
 	  ix86_isa_flags |= OPTION_MASK_ISA_XSAVEOPT;
8178f7
+	if (processor_alias_table[i].flags & PTA_PKU
8178f7
+	    && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_PKU))
8178f7
+	  ix86_isa_flags |= OPTION_MASK_ISA_PKU;
8178f7
 	if (processor_alias_table[i].flags & (PTA_PREFETCH_SSE | PTA_SSE))
8178f7
 	  x86_prefetch_sse = true;
8178f7
 
8178f7
@@ -4220,6 +4225,7 @@ ix86_valid_target_attribute_inner_p (tre
8178f7
     IX86_ATTR_ISA ("fxsr",	OPT_mfxsr),
8178f7
     IX86_ATTR_ISA ("xsave",	OPT_mxsave),
8178f7
     IX86_ATTR_ISA ("xsaveopt",	OPT_mxsaveopt),
8178f7
+    IX86_ATTR_ISA ("pku",	OPT_mpku),
8178f7
 
8178f7
     /* enum options */
8178f7
     IX86_ATTR_ENUM ("fpmath=",	OPT_mfpmath_),
8178f7
@@ -27042,6 +27048,10 @@ enum ix86_builtins
8178f7
   IX86_BUILTIN_CPU_IS,
8178f7
   IX86_BUILTIN_CPU_SUPPORTS,
8178f7
 
8178f7
+  /* PKU instructions.  */
8178f7
+  IX86_BUILTIN_RDPKRU,
8178f7
+  IX86_BUILTIN_WRPKRU,
8178f7
+
8178f7
   IX86_BUILTIN_MAX
8178f7
 };
8178f7
 
8178f7
@@ -27357,6 +27367,10 @@ static const struct builtin_description
8178f7
   { OPTION_MASK_ISA_RTM, CODE_FOR_xbegin, "__builtin_ia32_xbegin", IX86_BUILTIN_XBEGIN, UNKNOWN, (int) UNSIGNED_FTYPE_VOID },
8178f7
   { OPTION_MASK_ISA_RTM, CODE_FOR_xend, "__builtin_ia32_xend", IX86_BUILTIN_XEND, UNKNOWN, (int) VOID_FTYPE_VOID },
8178f7
   { OPTION_MASK_ISA_RTM, CODE_FOR_xtest, "__builtin_ia32_xtest", IX86_BUILTIN_XTEST, UNKNOWN, (int) INT_FTYPE_VOID },
8178f7
+
8178f7
+  /* RDPKRU and WRPKRU.  */
8178f7
+  { OPTION_MASK_ISA_PKU, CODE_FOR_rdpkru, "__builtin_ia32_rdpkru", IX86_BUILTIN_RDPKRU, UNKNOWN, (int) UNSIGNED_FTYPE_VOID },
8178f7
+  { OPTION_MASK_ISA_PKU, CODE_FOR_wrpkru, "__builtin_ia32_wrpkru", IX86_BUILTIN_WRPKRU, UNKNOWN, (int) VOID_FTYPE_UNSIGNED },
8178f7
 };
8178f7
 
8178f7
 /* Builtins with variable number of arguments.  */
8178f7
--- gcc/doc/extend.texi	(revision 231943)
8178f7
+++ gcc/doc/extend.texi	(revision 231945)
8178f7
@@ -10996,6 +10996,13 @@ void __builtin_ia32_xabort (status)
8178f7
 int __builtin_ia32_xtest ()
8178f7
 @end smallexample
8178f7
 
8178f7
+The following built-in functions are available when @option{-mpku} is used.
8178f7
+They generate reads and writes to PKRU.
8178f7
+@smallexample
8178f7
+void __builtin_ia32_wrpkru (unsigned int)
8178f7
+unsigned int __builtin_ia32_rdpkru ()
8178f7
+@end smallexample
8178f7
+
8178f7
 @node X86 transactional memory intrinsics
8178f7
 @subsection X86 transaction memory intrinsics
8178f7
 
8178f7
--- gcc/doc/invoke.texi	(revision 231943)
8178f7
+++ gcc/doc/invoke.texi	(revision 231945)
8178f7
@@ -645,7 +645,7 @@ Objective-C and Objective-C++ Dialects}.
8178f7
 -mmmx  -msse  -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
8178f7
 -mavx2 -maes -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma @gol
8178f7
 -msse4a -m3dnow -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop -mlzcnt @gol
8178f7
--mbmi2 -mrtm -mlwp -mthreads @gol
8178f7
+-mbmi2 -mrtm -mlwp -mpku -mthreads @gol
8178f7
 -mno-align-stringops  -minline-all-stringops @gol
8178f7
 -minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
8178f7
 -mpush-args  -maccumulate-outgoing-args  -m128bit-long-double @gol
8178f7
@@ -14326,6 +14326,8 @@ preferred alignment to @option{-mpreferr
8178f7
 @itemx -mlzcnt
8178f7
 @itemx -mno-lzcnt
8178f7
 @itemx -mrtm
8178f7
+@itemx -mpku
8178f7
+@itemx -mno-pku
8178f7
 @itemx -mtbm
8178f7
 @itemx -mno-tbm
8178f7
 @opindex mmmx
8178f7
@@ -14336,7 +14338,7 @@ preferred alignment to @option{-mpreferr
8178f7
 @opindex mno-3dnow
8178f7
 These switches enable or disable the use of instructions in the MMX, SSE,
8178f7
 SSE2, SSE3, SSSE3, SSE4.1, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, F16C,
8178f7
-FMA, SSE4A, FMA4, XOP, LWP, ABM, BMI, BMI2, LZCNT, RTM or 3DNow!@:
8178f7
+FMA, SSE4A, FMA4, XOP, LWP, ABM, BMI, BMI2, LZCNT, RTM, PKU or 3DNow!@:
8178f7
 extended instruction sets.
8178f7
 These extensions are also available as built-in functions: see
8178f7
 @ref{X86 Built-in Functions}, for details of the functions enabled and
8178f7
--- gcc/testsuite/gcc.target/i386/sse-12.c	(revision 231943)
8178f7
+++ gcc/testsuite/gcc.target/i386/sse-12.c	(revision 231945)
8178f7
@@ -3,7 +3,7 @@
8178f7
    popcntintrin.h and mm_malloc.h are usable
8178f7
    with -O -std=c89 -pedantic-errors.  */
8178f7
 /* { dg-do compile } */
8178f7
-/* { dg-options "-O -std=c89 -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
8178f7
+/* { dg-options "-O -std=c89 -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
8178f7
 
8178f7
 #include <x86intrin.h>
8178f7
 
8178f7
--- gcc/testsuite/gcc.target/i386/sse-13.c	(revision 231943)
8178f7
+++ gcc/testsuite/gcc.target/i386/sse-13.c	(revision 231945)
8178f7
@@ -1,5 +1,5 @@
8178f7
 /* { dg-do compile } */
8178f7
-/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
8178f7
+/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
8178f7
 
8178f7
 #include <mm_malloc.h>
8178f7
 
8178f7
--- gcc/testsuite/gcc.target/i386/sse-22.c	(revision 231943)
8178f7
+++ gcc/testsuite/gcc.target/i386/sse-22.c	(revision 231945)
8178f7
@@ -268,7 +268,7 @@ test_2 (_mm_clmulepi64_si128, __m128i, _
8178f7
 
8178f7
 /* x86intrin.h (FMA4/XOP/LWP/BMI/BMI2/TBM/LZCNT/FMA). */
8178f7
 #ifdef DIFFERENT_PRAGMAS
8178f7
-#pragma GCC target ("fma4,xop,lwp,bmi,bmi2,tbm,lzcnt,fma,rdseed,prfchw,adx,fxsr,xsaveopt")
8178f7
+#pragma GCC target ("fma4,xop,lwp,bmi,bmi2,tbm,lzcnt,fma,rdseed,prfchw,adx,fxsr,xsaveopt,pku")
8178f7
 #endif
8178f7
 #include <x86intrin.h>
8178f7
 /* xopintrin.h */
8178f7
--- gcc/testsuite/gcc.target/i386/sse-23.c	(revision 231943)
8178f7
+++ gcc/testsuite/gcc.target/i386/sse-23.c	(revision 231945)
8178f7
@@ -183,7 +183,7 @@
8178f7
 /* rtmintrin.h */
8178f7
 #define __builtin_ia32_xabort(M) __builtin_ia32_xabort(1)
8178f7
 
8178f7
-#pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c,fma,rtm,rdseed,prfchw,adx,fxsr,xsaveopt")
8178f7
+#pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c,fma,rtm,rdseed,prfchw,adx,fxsr,xsaveopt,pku")
8178f7
 #include <wmmintrin.h>
8178f7
 #include <smmintrin.h>
8178f7
 #include <mm3dnow.h>
8178f7
--- gcc/testsuite/gcc.target/i386/rdpku-1.c	(revision 0)
8178f7
+++ gcc/testsuite/gcc.target/i386/rdpku-1.c	(revision 231945)
8178f7
@@ -0,0 +1,11 @@
8178f7
+/* { dg-do compile } */
8178f7
+/* { dg-options "-mpku -O2" } */
8178f7
+/* { dg-final { scan-assembler "rdpkru\n" } } */
8178f7
+
8178f7
+#include <x86intrin.h>
8178f7
+
8178f7
+unsigned extern
8178f7
+rdpku_test (void)
8178f7
+{
8178f7
+  return _rdpkru_u32 ();
8178f7
+}
8178f7
--- gcc/testsuite/gcc.target/i386/wrpku-1.c	(revision 0)
8178f7
+++ gcc/testsuite/gcc.target/i386/wrpku-1.c	(revision 231945)
8178f7
@@ -0,0 +1,11 @@
8178f7
+/* { dg-do compile } */
8178f7
+/* { dg-options "-mpku -O2" } */
8178f7
+/* { dg-final { scan-assembler "wrpkru\n" } } */
8178f7
+
8178f7
+#include <x86intrin.h>
8178f7
+
8178f7
+void extern
8178f7
+wrpku_test (unsigned int key)
8178f7
+{
8178f7
+  _wrpkru (key);
8178f7
+}
8178f7
--- gcc/testsuite/g++.dg/other/i386-2.C	(revision 231943)
8178f7
+++ gcc/testsuite/g++.dg/other/i386-2.C	(revision 231945)
8178f7
@@ -1,9 +1,9 @@
8178f7
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
8178f7
-/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
8178f7
+/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
8178f7
 
8178f7
 /* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h,
8178f7
    xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h,
8178f7
-   popcntintrin.h, fmaintrin.h and mm_malloc.h.h are usable with 
8178f7
+   popcntintrin.h, fmaintrin.h, pkuintrin.h and mm_malloc.h.h are usable with 
8178f7
    -O -pedantic-errors.  */
8178f7
 
8178f7
 #include <x86intrin.h>
8178f7
--- gcc/testsuite/g++.dg/other/i386-3.C	(revision 231943)
8178f7
+++ gcc/testsuite/g++.dg/other/i386-3.C	(revision 231945)
8178f7
@@ -1,9 +1,9 @@
8178f7
 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
8178f7
-/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
8178f7
+/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
8178f7
 
8178f7
 /* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h,
8178f7
    xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h,
8178f7
-   popcntintrin.h, fmaintrin.h and mm_malloc.h are usable with
8178f7
+   popcntintrin.h, fmaintrin.h, pkuintrin.h and mm_malloc.h are usable with
8178f7
    -O -fkeep-inline-functions.  */
8178f7
 
8178f7
 #include <x86intrin.h>