From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id 6A1A53858CDA for ; Tue, 26 Jul 2022 01:31:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A1A53858CDA X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="285380879" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="285380879" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 18:31:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="845697035" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga006.fm.intel.com with ESMTP; 25 Jul 2022 18:31:07 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 25 Jul 2022 18:31:06 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Mon, 25 Jul 2022 18:31:06 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Mon, 25 Jul 2022 18:31:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRJJpzkKwU9Xl3iMiZHpQtYjJcWOsNPcP1QkcUeOA70wk7YuSnnNk3qekysbPjetRTLu924fGXnvcPWkCfDxyNgSFDZL8o9+HE9l/rbuuqq0PLRZ1+ayK2qu0Rv9FCSSH+3DqwMRIbaQD06EJtZ9qDS4BZIojPaH497w+MYEDwFnXFRwZqrlQ8mRpVMgieE2p3L0b0ra4HArJhsMWDIgNwYx708HPenPsWfRvEUebKI+iFPQjXm5Sm+BXnNIAFvIXa63Hmj0J1kXv/Yc2ogdYF0s2CX2XiWmciWmIHQRxbja46++Em2KPxON2xCNet7aJN+Du+KbGTTRApe8oTo8AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RMLBWZhxo1m/EOy56jluVdPEsUurdOy8F6iuNhRGVcA=; b=hmhuQaNSSG0Q8d9NhbNpErTq4JU43dICJgNOc+AIty7P2QFxkDmNpd1JdtG0HGP/GONs16kRflopesXtVYCCxx3uwjT9Uf7yJKCwDkCFORoVzZFd3Q/l1IPiCYV8aA/WFeN7OFzadkqS1OydPwwO1Kr/UPopF+LB6MsKqZHwj3rGoWaMK4J9TJgwPB2lBKjnapF7eT7PN8W1muZsueaZDS/K+p6KLh56JnHb3GikG0+c4eQXeZGiiENOGLFc+RnSOo21Opaah0MS31ncdlr6vrurktLYnz/FIPEEF/7cGxsFqK5/1UwNJi0TO7VZzVBBBOfCrLLoK1KmQBQ6QYe1hQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB5487.namprd11.prod.outlook.com (2603:10b6:5:39f::22) by PH0PR11MB5612.namprd11.prod.outlook.com (2603:10b6:510:e7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Tue, 26 Jul 2022 01:31:03 +0000 Received: from DM4PR11MB5487.namprd11.prod.outlook.com ([fe80::d0fb:381e:3499:e048]) by DM4PR11MB5487.namprd11.prod.outlook.com ([fe80::d0fb:381e:3499:e048%9]) with mapi id 15.20.5458.025; Tue, 26 Jul 2022 01:31:03 +0000 From: "Kong, Lingling" To: "Liu, Hongtao" , "gcc-patches@gcc.gnu.org" Subject: [PATCH] x86: Enable __bf16 type for TARGET_SSE2 and above Thread-Topic: [PATCH] x86: Enable __bf16 type for TARGET_SSE2 and above Thread-Index: AQHYoI0DcrOQRHlIPkegbMwKUvZ/vK2P2RDg Date: Tue, 26 Jul 2022 01:31:03 +0000 Message-ID: References: <20220726011357.12001-1-lingling.kong@intel.com> In-Reply-To: <20220726011357.12001-1-lingling.kong@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8d853c27-bf7e-4d52-fdc4-08da6ea680fd x-ms-traffictypediagnostic: PH0PR11MB5612:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 27QqRX9mj6Kll1qEtu0vOAa4PFceWLcED6BKrubHaDHNQiQ1L6A/UmoUn5PbEYBT9OjPKlWKO+HjwaGJ5DrDLc6r86heXVALOIi4bhi82u/HsWlFD728PYRIWUjTlUehkrgifXAdFQuc3PksbfcxM9RQEJwoOn20P/LjSgKvKf9bjTWt9yD5FI7a7FqhBpIpSKZuKNMDT12+cM9Qq2B++PbnLkJEZwWhX7Y6iO33ngj0uHt/OXHBZsBHXvquJAmR3g7cwA2Fqw80GpragjkPBc4Kp/GW6oK6f7rsp0XUpvHWI6ZQEbix9xbQvnvUoPJHvBTMzc4msB1tSRFBqtLShbQbkrUGlOgKaXhkomkrr33MKRt5ApubIFB0K9DdCRqQ8i/Vam7aNHxrxtdZVYscK4VrT2GIHIeeUhXvCvrJw3IhLRN0clZiOnbxk3g2Uf5tKGu5xxcQ1AZe/PeGqMnARsSYnytxthOLhZJYLxElqXasnFEFnqjbu6eytYXffcz6zubceDh/MmhSoMudpd6zdsbPiPodwI4H3OiKVdfsgA3Lki1lPGUw8wk5KdPZVBCmUnSYrfztxqocdfWOulUnN+T3ArKejazkt5A9ZKue7xJ5p1GTysyjEmSYb8XPyVKMZaBWkOR0Pc6ar3svWb7iBAYmK6M04yoWxds4xtnGI7qfiR/uWNJ8Da/S3ztegwPUoBWk5kiNAg3T9hgxzmEQSOsAoZrpMnoPzYbxa9viG6RR0zrFTVBmy3+gK8pPF2FsSFfXGQsjiF7MxBc5n03n9h0KmXSPay4aBYO0QC8wl+Fbf0ESx8SQ8AwISmCb72sp5ywNTZBg1r3DRbN4zlsWqA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5487.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(366004)(346002)(376002)(396003)(136003)(66556008)(82960400001)(71200400001)(66446008)(66476007)(66946007)(76116006)(84970400001)(186003)(41300700001)(64756008)(4326008)(8676002)(2906002)(30864003)(5660300002)(38070700005)(83380400001)(966005)(52536014)(55016003)(8936002)(478600001)(33656002)(122000001)(107886003)(86362001)(316002)(110136005)(38100700002)(9686003)(6506007)(26005)(7696005)(579004)(559001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rueik2RIVOmp7oamlPAT/2oUrCktxyNbv0pKcBbjykl7bncjeh9fo5jbQJ9B?= =?us-ascii?Q?mYPmBlGvl7dDRUmQLzvlE8gpzZIkZ9El6vTbyDkfM4xBj8i2Gy5FkpwrnXaz?= =?us-ascii?Q?SxF3lJOii6m2KQ5KpZHIivV08AX3W0piBwc3OYGAsjSRzDS7zNk2HIIIeIhR?= =?us-ascii?Q?+m73Au61w4W1amQIKnGSNj+7Uz10IUi6ThmcToBMgQZKp1Y4nVS7GpjCBxiB?= =?us-ascii?Q?DBGm5vBr7zqPCCA5O3KCa2qjPZERD0DtHQbDyz+zVR9WHRGv+juVQykPs3Zj?= =?us-ascii?Q?CwHJYTs6tgxpYDpsJnCBe6YctvSIKstFbsWb5O/gjNbcEkA8aP3JRtxYgJ5s?= =?us-ascii?Q?iCdRSgRPKWLf5flNgHOljgbQg79Ck2+5IKnjlB9BBlYiIRiuxwW/ulhjkIId?= =?us-ascii?Q?ACmD58zx0K/17v3S3/QixQaamBtra7eVbWhurF+qbzPFdFktojpZoZcVrIgx?= =?us-ascii?Q?1FIN9P9DxYtD8/l6hC9etksF3CauLapQ5+bkBjVGXt/fyoGBRlmmwFfnF44W?= =?us-ascii?Q?CgIFIGAusOOYtP/XEInoFVC34ZOgzemyTATF1s3TcEYFlcrjTE6AsijUjtaw?= =?us-ascii?Q?PUyuvz35U6cGNdxfpFv4oHZMkVBW6+ylXUTxpSLoFkAlKljKfkInElt7McvC?= =?us-ascii?Q?NqbcJFmmk3BOPpCSgmMHm0MK+W1XF6ZESDGjBjFLMWoz4gr5dNkH0IOqATAU?= =?us-ascii?Q?hIcUfmWlZt6SUK2ATRbf2adubMT6t0oM8gelPQZVtqfBzwXCEsdxg6HqIcxU?= =?us-ascii?Q?jo0CvAU4wYFdF8mcuk0xNTSnOkuho8LBTXaVS2N/sqcgQ9V1No29KWIGlBHx?= =?us-ascii?Q?4IrdzuxjAav+JAmhpk33BxP6PQfi5hpBa16wZX2rpXILRGTWS2UnfnOmubIh?= =?us-ascii?Q?HLsakhaLofYkT9bGuh5sGQhVT7TUO04313H/jnsUSdnU02eYrWzbLe8+BMuh?= =?us-ascii?Q?Ghk+KLzulxp1Gm0y3Xy6KfedsExVTp3KU03UpnBmfSf1TyENmKG0WQEQhK65?= =?us-ascii?Q?A35s6mvvxzPdR13KYQfm4SYKkXQyjRZTGxfYLVfrlca69UE8xFUd9XGPreg6?= =?us-ascii?Q?QcDpXP0mboRHAS+lTvJRIBd6dfDK0/3xIG+SGxaccwZYeOCqZvZbMn5z2SZ0?= =?us-ascii?Q?EFDC6+rQ9jcjzTD4LJiqJKqeOUJWnJVRKjLhZQQ94rds0o607pDV1KXqMsS+?= =?us-ascii?Q?Yw1A0E9T2RSKMXQxfFWpqJOlH8koPFsO5A7sUQvbFxgZUuHk/TGym2PJ51D/?= =?us-ascii?Q?VjRx1xLvcoFQ9rMnZrsuM7Gk+Ocvsv95tiPXfSoV8g3DEu4KAyeE08Op9oJ5?= =?us-ascii?Q?5KHDNCTpPIxr0wvFy88wkEg2tPDIvieSgtKrEvalRnxGbowPceTzCRFitCS2?= =?us-ascii?Q?3+ZbSlpp5/N8VjrY7ba6DklcYYLWazrs2uXKO3ld3XTvMMy1YqmsVs5crCIo?= =?us-ascii?Q?bXOukHtNuw8gfrL7aKyCpFwDLFsplNx2a7uLOjE7g0IijxS9+MPsa3AQR0pf?= =?us-ascii?Q?rUk5qvU/KrqenFx9UcVg/uIXG6KUKp9J9LEw0dctAfJeEJKSB52itbACiBOL?= =?us-ascii?Q?VaIEB0C/Yp7oHRbZCxcjmyjme8euVQIq6nG6KBM2?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5487.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d853c27-bf7e-4d52-fdc4-08da6ea680fd X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2022 01:31:03.3789 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VoJPeeVJuVncPrwi7+GnYrSbtP+isHWmMx4R1IGgN0WL5Byh9p9GQnOi1SQE8YxpTIIK4khg7VlibUH91hZm6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5612 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2022 01:31:13 -0000 Hi, The patch is enable __bf16 scalar type for target sse2 and above according = to psABI(https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/35/diffs= ). The __bf16 type is a storage type like arm. OK for master? gcc/ChangeLog: * config/i386/i386-builtin-types.def (BFLOAT16): New primitive type. * config/i386/i386-builtins.cc : Support __bf16 type for i386 backend. (ix86_register_bf16_builtin_type): New function. (ix86_bf16_type_node): New. (ix86_bf16_ptr_type_node): Ditto. (ix86_init_builtin_types): Add ix86_register_bf16_builtin_type function ca= ll. * config/i386/i386-modes.def (FLOAT_MODE): Add BFmode. (ADJUST_FLOAT_FORMAT): Ditto. * config/i386/i386.cc (merge_classes): Handle BFmode. (classify_argument): Ditto. (examine_argument): Ditto. (construct_container): Ditto. (function_value_32): Return __bf16 by %xmm0. (function_value_64): Return __bf16 by SSE register. (ix86_print_operand): Handle CONST_DOUBLE BFmode. (ix86_secondary_reload): Require gpr as intermediate register to store __bf16 from sse register when sse4 is not available. (ix86_scalar_mode_supported_p): Enable __bf16 under sse2. (ix86_mangle_type): Add manlging for __bf16 type. (ix86_invalid_conversion): New function for target hook. (ix86_invalid_unary_op): Ditto. (ix86_invalid_binary_op): Ditto. (TARGET_INVALID_CONVERSION): New define for target hook. (TARGET_INVALID_UNARY_OP): Ditto. (TARGET_INVALID_BINARY_OP): Ditto. * config/i386/i386.h (host_detect_local_cpu): Add BFmode. * config/i386/i386.md (*pushhf_rex64): Change for BFmode. (*push_rex64): Ditto. (*pushhf): Ditto. (*push): Ditto. (*movhf_internal): Ditto. (*mov_internal): Ditto. gcc/testsuite/ChangeLog: * g++.target/i386/bfloat_cpp_typecheck.C: New test. * gcc.target/i386/bfloat16-1.c: Ditto. * gcc.target/i386/sse2-bfloat16-1.c: Ditto. * gcc.target/i386/sse2-bfloat16-2.c: Ditto. * gcc.target/i386/sse2-bfloat16-scalar-typecheck.c: Ditto. --- gcc/config/i386/i386-builtin-types.def | 1 + gcc/config/i386/i386-builtins.cc | 21 ++ gcc/config/i386/i386-modes.def | 2 + gcc/config/i386/i386.cc | 75 +++++- gcc/config/i386/i386.h | 4 +- gcc/config/i386/i386.md | 32 +-- .../g++.target/i386/bfloat_cpp_typecheck.C | 10 + gcc/testsuite/gcc.target/i386/bfloat16-1.c | 12 + .../gcc.target/i386/sse2-bfloat16-1.c | 8 + .../gcc.target/i386/sse2-bfloat16-2.c | 17 ++ .../i386/sse2-bfloat16-scalar-typecheck.c | 215 ++++++++++++++++++ 11 files changed, 375 insertions(+), 22 deletions(-) create mode 100644 g= cc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C create mode 100644 gcc/testsuite/gcc.target/i386/bfloat16-1.c create mode 100644 gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c create mode 100644 gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c create mode 100644 gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-type= check.c diff --git a/gcc/config/i386/i386-builtin-types.def b/gcc/config/i386/i386-= builtin-types.def index 7a2da1db0b0..63a360b0f8b 100644 --- a/gcc/config/i386/i386-builtin-types.def +++ b/gcc/config/i386/i386-builtin-types.def @@ -69,6 +69,7 @@ DEF_PRIMITIVE_TYPE (UINT16, short_unsigned_type_node) DE= F_PRIMITIVE_TYPE (INT64, long_long_integer_type_node) DEF_PRIMITIVE_TYPE (= UINT64, long_long_unsigned_type_node) DEF_PRIMITIVE_TYPE (FLOAT16, ix86_fl= oat16_type_node) +DEF_PRIMITIVE_TYPE (BFLOAT16, ix86_bf16_type_node) DEF_PRIMITIVE_TYPE (FLOAT, float_type_node) DEF_PRIMITIVE_TYPE (DOUBLE, d= ouble_type_node) DEF_PRIMITIVE_TYPE (FLOAT80, float80_type_node) diff --gi= t a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc index fe7243c3837..6a04fb57e65 100644 --- a/gcc/config/i386/i386-builtins.cc +++ b/gcc/config/i386/i386-builtins.cc @@ -126,6 +126,9 @@ BDESC_VERIFYS (IX86_BUILTIN_MAX, static GTY(()) tree i= x86_builtin_type_tab[(int) IX86_BT_LAST_CPTR + 1]; =20 tree ix86_float16_type_node =3D NULL_TREE; +tree ix86_bf16_type_node =3D NULL_TREE; +tree ix86_bf16_ptr_type_node =3D NULL_TREE; + /* Retrieve an element from the above table, building some of the types lazily. */ =20 @@ -1366,6 +1369,22 @@ ix86_register_float16_builtin_type (void) "_Float16"); } =20 +static void +ix86_register_bf16_builtin_type (void) +{ + ix86_bf16_type_node =3D make_node (REAL_TYPE); + TYPE_PRECISION (ix86_bf16_type_node) =3D 16; + SET_TYPE_MODE (ix86_bf16_type_node, BFmode); + layout_type (ix86_bf16_type_node); + + if (!maybe_get_identifier ("__bf16") && TARGET_SSE2) + { + lang_hooks.types.register_builtin_type (ix86_bf16_type_node, + "__bf16"); + ix86_bf16_ptr_type_node =3D build_pointer_type (ix86_bf16_type_node)= ; + } +} + static void ix86_init_builtin_types (void) { @@ -1396,6 +1415,8 @@ ix86_init_builtin_types (void) =20 ix86_register_float16_builtin_type (); =20 + ix86_register_bf16_builtin_type (); + const_string_type_node =3D build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST)); diff --git a/gcc/config/i386/i386= -modes.def b/gcc/config/i386/i386-modes.def index e2e1e18d24d..b49daaef253 = 100644 --- a/gcc/config/i386/i386-modes.def +++ b/gcc/config/i386/i386-modes.def @@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see FRACT= IONAL_FLOAT_MODE (XF, 80, 12, ieee_extended_intel_96_format); FLOAT_MODE (= TF, 16, ieee_quad_format); FLOAT_MODE (HF, 2, ieee_half_format); +FLOAT_MODE (BF, 2, 0); +ADJUST_FLOAT_FORMAT (BF, &arm_bfloat_half_format); =20 /* In ILP32 mode, XFmode has size 12 and alignment 4. In LP64 mode, XFmode has size and alignment 16. */ diff --git a/gcc/co= nfig/i386/i386.cc b/gcc/config/i386/i386.cc index e03f86d4a23..5d589f6a05c = 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -2399,6 +2399,7 @@ classify_argument (machine_mode mode, const_tree type= , case E_CTImode: return 0; case E_HFmode: + case E_BFmode: if (!(bit_offset % 64)) classes[0] =3D X86_64_SSEHF_CLASS; else @@ -2792,9 +2793,10 @@ construct_container (machine_mode mode, machine_mode= orig_mode, intreg++; break; case X86_64_SSEHF_CLASS: + tmpmode =3D (mode =3D=3D BFmode ? BFmode : HFmode); exp [nexps++] =3D gen_rtx_EXPR_LIST (VOIDmode, - gen_rtx_REG (HFmode, + gen_rtx_REG (tmpmode, GET_SSE_REGNO (sse_regno)), GEN_INT (i*8)); sse_regno++; @@ -4001,8 +4003,8 @@ function_value_32 (machine_mode orig_mode, machine_mo= de mode, /* Most things go in %eax. */ regno =3D AX_REG; =20 - /* Return _Float16/_Complex _Foat16 by sse register. */ - if (mode =3D=3D HFmode) + /* Return __bf16/ _Float16/_Complex _Foat16 by sse register. */ if=20 + (mode =3D=3D HFmode || mode =3D=3D BFmode) regno =3D FIRST_SSE_REG; if (mode =3D=3D HCmode) { @@ -4050,6 +4052,7 @@ function_value_64 (machine_mode orig_mode, machine_mo= de mode, =20 switch (mode) { + case E_BFmode: case E_HFmode: case E_HCmode: case E_SFmode: @@ -5631,6 +5634,7 @@ ix86_output_ssemov (rtx_insn *insn, rtx *operands) return "%vmovss\t{%1, %0|%0, %1}"; =20 case MODE_HF: + case MODE_BF: if (REG_P (operands[0]) && REG_P (operands[1])) return "vmovsh\t{%d1, %0|%0, %d1}"; else @@ -19402,7 +19406,8 @@ ix86_secondary_reload (bool in_p, rtx x, reg_class_= t rclass, } =20 /* Require movement to gpr, and then store to memory. */ - if ((mode =3D=3D HFmode || mode =3D=3D HImode || mode =3D=3D V2QImode) + if ((mode =3D=3D HFmode || mode =3D=3D HImode || mode =3D=3D V2QImode + || mode =3D=3D BFmode) && !TARGET_SSE4_1 && SSE_CLASS_P (rclass) && !in_p && MEM_P (x)) @@ -22331,7 +22336,7 @@ ix86_scalar_mode_supported_p (scalar_mode mode) return default_decimal_float_supported_p (); else if (mode =3D=3D TFmode) return true; - else if (mode =3D=3D HFmode && TARGET_SSE2) + else if ((mode =3D=3D HFmode || mode =3D=3D BFmode) && TARGET_SSE2) return true; else return default_scalar_mode_supported_p (mode); @@ -22646,6 +22651,8 @@= ix86_mangle_type (const_tree type) =20 switch (TYPE_MODE (type)) { + case E_BFmode: + return "u6__bf16"; case E_HFmode: /* _Float16 is "DF16_". Align with clang's decision in https://reviews.llvm.org/D33719. */ @@ -2= 2661,6 +22668,55 @@ ix86_mangle_type (const_tree type) } } =20 +/* Return the diagnostic message string if conversion from FROMTYPE to + TOTYPE is not allowed, NULL otherwise. */ + +static const char * +ix86_invalid_conversion (const_tree fromtype, const_tree totype) { + if (element_mode (fromtype) !=3D element_mode (totype)) + { + /* Do no allow conversions to/from BFmode scalar types. */ + if (TYPE_MODE (fromtype) =3D=3D BFmode) + return N_("invalid conversion from type %<__bf16%>"); + if (TYPE_MODE (totype) =3D=3D BFmode) + return N_("invalid conversion to type %<__bf16%>"); + } + + /* Conversion allowed. */ + return NULL; +} + +/* Return the diagnostic message string if the unary operation OP is + not permitted on TYPE, NULL otherwise. */ + +static const char * +ix86_invalid_unary_op (int op, const_tree type) { + /* Reject all single-operand operations on BFmode except for &. */ + if (element_mode (type) =3D=3D BFmode && op !=3D ADDR_EXPR) + return N_("operation not permitted on type %<__bf16%>"); + + /* Operation allowed. */ + return NULL; +} + +/* Return the diagnostic message string if the binary operation OP is + not permitted on TYPE1 and TYPE2, NULL otherwise. */ + +static const char * +ix86_invalid_binary_op (int op ATTRIBUTE_UNUSED, const_tree type1, + const_tree type2) +{ + /* Reject all 2-operand operations on BFmode. */ + if (element_mode (type1) =3D=3D BFmode + || element_mode (type2) =3D=3D BFmode) + return N_("operation not permitted on type %<__bf16%>"); + + /* Operation allowed. */ + return NULL; +} + static GTY(()) tree ix86_tls_stack_chk_guard_decl; =20 static tree @@ -24718,6 +24774,15 @@ ix86_libgcc_floating_mode_supported_p #undef TARGET_MANGLE_TYPE #define TARGET_MANGLE_TYPE ix86_mangle_type =20 +#undef TARGET_INVALID_CONVERSION +#define TARGET_INVALID_CONVERSION ix86_invalid_conversion + +#undef TARGET_INVALID_UNARY_OP +#define TARGET_INVALID_UNARY_OP ix86_invalid_unary_op + +#undef TARGET_INVALID_BINARY_OP +#define TARGET_INVALID_BINARY_OP ix86_invalid_binary_op + #undef TARGET_STACK_PROTECT_GUARD #define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard =20 diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index f16df633= e84..0da3dce1d31 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1046,7 +1046,7 @@ extern const char *host_detect_local_cpu (int argc, c= onst char **argv); || (MODE) =3D=3D V8HFmode || (MODE) =3D=3D V4HFmode || (MODE) =3D=3D V2= HFmode \ || (MODE) =3D=3D V4QImode || (MODE) =3D=3D V2HImode || (MODE) =3D=3D V1= SImode \ || (MODE) =3D=3D V2DImode || (MODE) =3D=3D V2QImode || (MODE) =3D=3D DF= mode \ - || (MODE) =3D=3D HFmode) + || (MODE) =3D=3D HFmode || (MODE) =3D=3D BFmode) =20 #define VALID_SSE_REG_MODE(MODE) \ ((MODE) =3D=3D V1TImode || (MODE) =3D=3D TImode \ @@ -1077,7 +1077,7 @@ extern const char *host_detect_local_cpu (int argc, c= onst char **argv); || (MODE) =3D=3D CQImode || (MODE) =3D=3D CHImode \ || (MODE) =3D=3D CSImode || (MODE) =3D=3D CDImode \ || (MODE) =3D=3D SDmode || (MODE) =3D=3D DDmode \ - || (MODE) =3D=3D HFmode || (MODE) =3D=3D HCmode \ + || (MODE) =3D=3D HFmode || (MODE) =3D=3D HCmode || (MODE) =3D=3D BFmode= \ || (MODE) =3D=3D V2HImode || (MODE) =3D=3D V2HFmode \ || (MODE) =3D=3D V1SImode || (MODE) =3D=3D V4QImode || (MODE) =3D=3D V2= QImode \ || (TARGET_64BIT \ diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 9aaeb6= 95f0f..1f7b018913a 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -499,7 +499,7 @@ =20 ;; Main data type used by the insn (define_attr "mode" - "unknown,none,QI,HI,SI,DI,TI,OI,XI,HF,SF,DF,XF,TF,V32HF,V16HF,V8HF, + =20 + "unknown,none,QI,HI,SI,DI,TI,OI,XI,HF,BF,SF,DF,XF,TF,V32HF,V16HF,V8HF, V16SF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF,V8DF,V4HF,V2HF" (const_string "unknown")) =20 @@ -1104,7 +1104,7 @@ ;; GET_MODE_SIZE (mode). For XFmode which depends on ;; command li= ne options just use GET_MODE_SIZE macro. (define_mode_attr MODE_SIZE [(QI "1") (HI "2") (SI "4") (DI "8") - (TI "16") (HF "2") (SF "4") (DF "8") + (TI "16") (HF "2") (BF "2") (SF "4") (DF "8") (XF "GET_MODE_SIZE (XFmode)") (V16QI "16") (V32QI "32") (V64QI "64") (V8HI "16") (V16HI "32") (V32HI "64") @@ -1248,7 +1248,7 @@ (defi= ne_mode_iterator X87MODEF [SF DF XF]) =20 ;; All x87 floating point modes plus HFmode -(define_mode_iterator X87MODE= FH [HF SF DF XF]) +(define_mode_iterator X87MODEFH [HF SF DF XF BF]) =20 ;; All SSE floating point modes (define_mode_iterator SSEMODEF [HF SF DF TF]) @@ -3408,9 +3408,11 @@ operands[0] =3D replace_equiv_address (operands[0], stack_pointer_rtx); }) =20 -(define_insn "*pushhf_rex64" - [(set (match_operand:HF 0 "push_operand" "=3DX,X") - (match_operand:HF 1 "nonmemory_no_elim_operand" "r,x"))] +(define_mode_iterator HFBF [HF BF]) + +(define_insn "*push_rex64" + [(set (match_operand:HFBF 0 "push_operand" "=3DX,X") + (match_operand:HFBF 1 "nonmemory_no_elim_operand" "r,x"))] "TARGET_64BIT" { /* Anything else should be already split before reg-stack. */ @@ -3421,= 9 +3423,9 @@ (set_attr "type" "push,multi") (set_attr "mode" "DI,TI")]) =20 -(define_insn "*pushhf" - [(set (match_operand:HF 0 "push_operand" "=3DX,X") - (match_operand:HF 1 "general_no_elim_operand" "rmF,x"))] +(define_insn "*push" + [(set (match_operand:HFBF 0 "push_operand" "=3DX,X") + (match_operand:HFBF 1 "general_no_elim_operand" "rmF,x"))] "!TARGET_64BIT" { /* Anything else should be already split before reg-stack. */ @@ -3462,= 7 +3464,7 @@ (set_attr "unit" "i387,*,*") (set_attr "mode" "SF,SI,SF")]) =20 -(define_mode_iterator MODESH [SF HF]) +(define_mode_iterator MODESH [SF HF BF]) ;; %%% Kill this when call knows how to work this out. (define_split [(set (match_operand:MODESH 0 "push_operand") @@ -3950,18 +3952,18 @@ ] (const_string "*")))]) =20 -(define_insn "*movhf_internal" - [(set (match_operand:HF 0 "nonimmediate_operand" +(define_insn "*mov_internal" + [(set (match_operand:HFBF 0 "nonimmediate_operand" "=3D?r,?r,?r,?m,v,v,?r,m,?v,v") - (match_operand:HF 1 "general_operand" + (match_operand:HFBF 1 "general_operand" "r ,F ,m ,rF,C,v, v,v,r ,m"))] "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (lra_in_progress || reload_completed || !CONST_DOUBLE_P (operands[1]) || (TARGET_SSE2 - && standard_sse_constant_p (operands[1], HFmode) =3D=3D 1) - || memory_operand (operands[0], HFmode))" + && standard_sse_constant_p (operands[1], mode) =3D=3D 1) + || memory_operand (operands[0], mode))" { switch (get_attr_type (insn)) { diff --git a/gcc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C b/gcc/tes= tsuite/g++.target/i386/bfloat_cpp_typecheck.C new file mode 100644 index 00000000000..962c8504775 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C @@ -0,0 +1,10 @@ +/* { dg-do assemble { target sse2} } */ +/* { dg-options "-msse2 -O3 --save-temps" } */ + +void foo (void) +{ + __bf16 (); /* { dg-bogus {invalid conversion to type '__bf16'} } */ + __bf16 a =3D __bf16(); /* { dg-bogus {invalid conversion to type=20 +'__bf16'} } */ + __bf16 (0x1234); /* { dg-error {invalid conversion to type '__bf16'}=20 +} */ + __bf16 (0.1); /* { dg-error {invalid conversion to type '__bf16'} }=20 +*/ } diff --git a/gcc/testsuite/gcc.target/i386/bfloat16-1.c b/gcc/testsuite/gcc= .target/i386/bfloat16-1.c new file mode 100644 index 00000000000..6aaec28efd2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/bfloat16-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-msse2 -O2" } */ +__bf16 +foo (int a) +{ + union { + int a; + __bf16 b; + }c; + c.a =3D a; + return c.b; +} diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c b/gcc/testsuit= e/gcc.target/i386/sse2-bfloat16-1.c new file mode 100644 index 00000000000..612d55be826 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-sse2" } */ + +__bf16/* { dg-error "unknown type name '__bf16'" } */ foo (__bf16 x) /*=20 +{ dg-error "unknown type name '__bf16'" } */ { + return x; +} diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c b/gcc/testsuit= e/gcc.target/i386/sse2-bfloat16-2.c new file mode 100644 index 00000000000..a3286e26c48 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2 -mno-avx512f" } */ + +union flt +{ + __bf16 flt; + short s; +}; + +__bf16 +foo (union flt x) +{ + return x.flt; +} + +/* { dg-final { scan-assembler {(?n)pinsrw[\t ].*%xmm0} { target ia32 }=20 +} } */ +/* { dg-final { scan-assembler {(?n)movd[\t ].*%xmm0} { target { ! ia32=20 +} } } } */ diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c= b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c new file mode 100644 index 00000000000..f76d5547758 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c @@ -0,0 +1,215 @@ +/* { dg-do compile } */ +/* { dg-options "-msse2 -O2" } */ + + +__bf16 glob_bfloat; + +int is_an_int; +short is_a_short_int; +float is_a_float; +float is_a_float16; +double is_a_double; + +float *float_ptr; + +__bf16 foo1 (void) { return (__bf16) 0x1234; } /* { dg-error {invalid=20 +conversion to type '__bf16'} } */ +__bf16 foo2 (void) { return (__bf16) (short) 0x1234; } /* { dg-error=20 +{invalid conversion to type '__bf16'} } */ + +__bf16 footest (__bf16 scalar0) +{ + + /* Initialisation */ + + __bf16 scalar1_1; + __bf16 scalar1_2 =3D glob_bfloat; + __bf16 scalar1_3 =3D 0; /* { dg-error {invalid conversion to type '__b= f16'} } */ + __bf16 scalar1_4 =3D 0.1; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + __bf16 scalar1_5 =3D is_a_float; /* { dg-error {invalid conversion to=20 + type '__bf16'} } */ + __bf16 scalar1_6 =3D is_an_int; /* { dg-error {invalid conversion to=20 + type '__bf16'} } */ + __bf16 scalar1_7 =3D is_a_float16; /* { dg-error {invalid conversion to= =20 + type '__bf16'} } */ + __bf16 scalar1_8 =3D is_a_double; /* { dg-error {invalid conversion to=20 + type '__bf16'} } */ + __bf16 scalar1_9 =3D is_a_short_int; /* { dg-error {invalid conversion=20 + to type '__bf16'} } */ + + int initi_1_1 =3D glob_bfloat; /* { dg-error {invalid conversion from=20 + type '__bf16'} } */ float initi_1_2 =3D glob_bfloat; /* { dg-error=20 + {invalid conversion from type '__bf16'} } */ + _Float16 initi_1_3 =3D glob_bfloat; /* { dg-error {invalid conversion=20 + from type '__bf16'} } */ short initi_1_4 =3D glob_bfloat; /* { dg-error= =20 + {invalid conversion from type '__bf16'} } */ double initi_1_5 =3D=20 + glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} }=20 + */ + + __bf16 scalar2_1 =3D {}; /* { dg-error {empty scalar initializer} } */ + __bf16 scalar2_2 =3D { glob_bfloat }; + __bf16 scalar2_3 =3D { 0 }; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + __bf16 scalar2_4 =3D { 0.1 }; /* { dg-error {invalid conversion to type= =20 + '__bf16'} } */ + __bf16 scalar2_5 =3D { is_a_float }; /* { dg-error {invalid conversion=20 + to type '__bf16'} } */ + __bf16 scalar2_6 =3D { is_an_int }; /* { dg-error {invalid conversion=20 + to type '__bf16'} } */ + __bf16 scalar2_7 =3D { is_a_float16 }; /* { dg-error {invalid=20 + conversion to type '__bf16'} } */ + __bf16 scalar2_8 =3D { is_a_double }; /* { dg-error {invalid conversion= =20 + to type '__bf16'} } */ + __bf16 scalar2_9 =3D { is_a_short_int }; /* { dg-error {invalid=20 + conversion to type '__bf16'} } */ + + int initi_2_1 =3D { glob_bfloat }; /* { dg-error {invalid conversion=20 + from type '__bf16'} } */ float initi_2_2 =3D { glob_bfloat }; /* {=20 + dg-error {invalid conversion from type '__bf16'} } */ + _Float16 initi_2_3 =3D { glob_bfloat }; /* { dg-error {invalid=20 + conversion from type '__bf16'} } */ short initi_2_4 =3D { glob_bfloat=20 + }; /* { dg-error {invalid conversion from type '__bf16'} } */ double=20 + initi_2_5 =3D { glob_bfloat }; /* { dg-error {invalid conversion from=20 + type '__bf16'} } */ + + /* Assignments. */ + + glob_bfloat =3D glob_bfloat; + glob_bfloat =3D 0; /* { dg-error {invalid conversion to type '__bf16'}= } */ + glob_bfloat =3D 0.1; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ glob_bfloat =3D is_a_float; /* { dg-error {invalid=20 + conversion to type '__bf16'} } */ glob_bfloat =3D is_an_int; /* {=20 + dg-error {invalid conversion to type '__bf16'} } */ glob_bfloat =3D=20 + is_a_float16; /* { dg-error {invalid conversion to type '__bf16'} } */ =20 + glob_bfloat =3D is_a_double; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ glob_bfloat =3D is_a_short_int; /* { dg-error {invalid=20 + conversion to type '__bf16'} } */ + + is_an_int =3D glob_bfloat; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ is_a_float =3D glob_bfloat; /* { dg-error {invalid=20 + conversion from type '__bf16'} } */ + is_a_float16 =3D glob_bfloat; /* { dg-error {invalid conversion from=20 + type '__bf16'} } */ is_a_double =3D glob_bfloat; /* { dg-error {invalid= =20 + conversion from type '__bf16'} } */ is_a_short_int =3D glob_bfloat; /*=20 + { dg-error {invalid conversion from type '__bf16'} } */ + + /* Casting. */ + + (void) glob_bfloat; + (__bf16) glob_bfloat; + + (int) glob_bfloat; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (float) glob_bfloat; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (_Float16) glob_bfloat; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (double) glob_bfloat; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (short) glob_bfloat; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + + (__bf16) is_an_int; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) is_a_float; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) is_a_float16; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) is_a_double; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) is_a_short_int; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + + /* Compound literals. */ + + (__bf16) {}; /* { dg-error {empty scalar initializer} } */ + (__bf16) { glob_bfloat }; + (__bf16) { 0 }; /* { dg-error {invalid conversion to type '__bf16'} }=20 + */ + (__bf16) { 0.1 }; /* { dg-error {invalid conversion to type '__bf16'}=20 + } */ + (__bf16) { is_a_float }; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) { is_an_int }; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) { is_a_float16 }; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) { is_a_double }; /* { dg-error {invalid conversion to type=20 + '__bf16'} } */ + (__bf16) { is_a_short_int }; /* { dg-error {invalid conversion to=20 + type '__bf16'} } */ + + (int) { glob_bfloat }; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (float) { glob_bfloat }; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (_Float16) { glob_bfloat }; /* { dg-error {invalid conversion from=20 + type '__bf16'} } */ + (double) { glob_bfloat }; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + (short) { glob_bfloat }; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + + /* Arrays and Structs. */ + + typedef __bf16 array_type[2]; + extern __bf16 extern_array[]; + + __bf16 array[2]; + __bf16 zero_length_array[0]; + __bf16 empty_init_array[] =3D {}; + typedef __bf16 some_other_type[is_an_int]; + + struct struct1 { + __bf16 a; + }; + + union union1 { + __bf16 a; + }; + + /* Addressing and dereferencing. */ + + __bf16 *bfloat_ptr =3D &scalar0; + scalar0 =3D *bfloat_ptr; + + /* Pointer assignment. */ + + __bf16 *bfloat_ptr2 =3D bfloat_ptr; + __bf16 *bfloat_ptr3 =3D array; + + /* Pointer arithmetic. */ + + ++bfloat_ptr; + --bfloat_ptr; + bfloat_ptr++; + bfloat_ptr--; + bfloat_ptr +=3D 1; + bfloat_ptr -=3D 1; + bfloat_ptr - bfloat_ptr2; + bfloat_ptr =3D &bfloat_ptr3[0]; + bfloat_ptr =3D &bfloat_ptr3[1]; + + /* Simple comparison. */ + scalar0 > glob_bfloat; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ glob_bfloat =3D=3D scalar0; /* { dg-error {operation not= =20 + permitted on type '__bf16'} } */ + scalar0 > is_a_float; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ is_a_float =3D=3D scalar0; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + scalar0 > 0; /* { dg-error {operation not permitted on type '__bf16'}=20 + } */ + 0 =3D=3D scalar0; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ + scalar0 > 0.1; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ + 0.1 =3D=3D scalar0; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ + scalar0 > is_an_int; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ is_an_int =3D=3D scalar0; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + + /* Pointer comparison. */ + + bfloat_ptr =3D=3D &scalar0; + bfloat_ptr !=3D &scalar0; + bfloat_ptr < &scalar0; + bfloat_ptr <=3D &scalar0; + bfloat_ptr > &scalar0; + bfloat_ptr >=3D &scalar0; + bfloat_ptr =3D=3D bfloat_ptr2; + bfloat_ptr !=3D bfloat_ptr2; + bfloat_ptr < bfloat_ptr2; + bfloat_ptr <=3D bfloat_ptr2; + bfloat_ptr > bfloat_ptr2; + bfloat_ptr >=3D bfloat_ptr2; + + /* Conditional expressions. */ + + 0 ? scalar0 : scalar0; + 0 ? scalar0 : is_a_float; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + 0 ? is_a_float : scalar0; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + 0 ? scalar0 : 0; /* { dg-error {invalid conversion to type '__bf16'}=20 + } */ + 0 ? 0 : scalar0; /* { dg-error {invalid conversion to type '__bf16'}=20 + } */ + 0 ? 0.1 : scalar0; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + 0 ? scalar0 : 0.1; /* { dg-error {invalid conversion from type=20 + '__bf16'} } */ + 0 ? bfloat_ptr : bfloat_ptr2; + 0 ? bfloat_ptr : float_ptr; /* { dg-warning {pointer type mismatch in=20 + conditional expression} } */ + 0 ? float_ptr : bfloat_ptr; /* { dg-warning {pointer type mismatch in=20 + conditional expression} } */ + + scalar0 ? scalar0 : scalar0; /* { dg-error {operation not permitted=20 + on type '__bf16'} } */ + scalar0 ? is_a_float : scalar0; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + scalar0 ? scalar0 : is_a_float; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + scalar0 ? is_a_float : is_a_float; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + + /* Unary operators. */ + + +scalar0; /* { dg-error {operation not permitted on type '__bf16'} }=20 + */ -scalar0; /* { dg-error {operation not permitted on type '__bf16'}=20 + } */ ~scalar0; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ !scalar0; /* { dg-error {operation not permitted on=20 + type '__bf16'} } */ *scalar0; /* { dg-error {invalid type argument of=20 + unary '\*'} } */ __real scalar0; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ __imag scalar0; /* { dg-error=20 + {operation not permitted on type '__bf16'} } */ ++scalar0; /* {=20 + dg-error {operation not permitted on type '__bf16'} } */ --scalar0;=20 + /* { dg-error {operation not permitted on type '__bf16'} } */ =20 + scalar0++; /* { dg-error {operation not permitted on type '__bf16'} }=20 + */ scalar0--; /* { dg-error {operation not permitted on type=20 + '__bf16'} } */ + + /* Binary arithmetic operations. */ + + scalar0 =3D glob_bfloat + *bfloat_ptr; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + scalar0 =3D glob_bfloat + 0.1; /* { dg-error {operation not permitted=20 + on type '__bf16'} } */ + scalar0 =3D glob_bfloat + 0; /* { dg-error {operation not permitted on=20 + type '__bf16'} } */ + scalar0 =3D glob_bfloat + is_a_float; /* { dg-error {operation not=20 + permitted on type '__bf16'} } */ + + return scalar0; +} + -- 2.18.2