From patchwork Fri Nov 8 06:53:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Lin1" X-Patchwork-Id: 2008284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QsA4embl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xl8mY0wHXz1xyS for ; Fri, 8 Nov 2024 17:53:48 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F33DC3858D33 for ; Fri, 8 Nov 2024 06:53:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by sourceware.org (Postfix) with ESMTPS id A681C3858D20 for ; Fri, 8 Nov 2024 06:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A681C3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A681C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731048809; cv=none; b=MfTq5FZ4qv6Y553Xn54Oz6/ZdZWUv5RqnYwn5zYue9uWmqfzsoVmabvo9P6Cw4wLwtb48GrXV6BbJhQlBxR5hn9D8QtEiF4pT1aAUs6dp7rybAlDvccN9dtzskjvR5wujYNmwSPpn7SsysagWnnPbAfGxIKV5LAfxw365s4AZZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731048809; c=relaxed/simple; bh=EX8GrBMeiau/fgj4L0rbzkd9oCjpxaAlN6zZ0CdsKdI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=uBRlAbw5szJMPMSi2KIhO0/NYEoxECLVkHhORhQ45yGUnaRHXNVkwzUR+ctnT6JMnxnRK1MI88IryqELT8l4cN17xWA/juicLtZl+M+gdGnPSHYTdRl7JVtJO01POf5s66Ih6vyWXvMzYymTCDBM8QDpFWWUF+LnTNVd2TP40rc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731048803; x=1762584803; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EX8GrBMeiau/fgj4L0rbzkd9oCjpxaAlN6zZ0CdsKdI=; b=QsA4emblcRijqnzs17jhM9avASuOYog2EIaIhKDrsFl3lM9olNXO5JIn OhFqbJCkM3NKcgad3Zg9uqLFztWGde8GubhZwl+1tnlbkYIYE5nBoRJCd wX1NaYNjxCi34uznsTseazmtZC15mqxSJMPVVYA7tqX1L4cnh5WF2LqY6 MLhlL6wehG0Q9ht0rPVRiZDCPJ4x/8ez/Zl7VIQjZWZHXnHMPx9Wjhaez Da0XEVaaon+bwPgKmGduGTInPm8J8wZaYzjRlckgyOHSNeJONBdZPu9iY lntul3Wd9RhjM0uQVbgiIsD2W7mh0cIeLEssIW0kVbbBmhpG9F6eH8BNX Q==; X-CSE-ConnectionGUID: Y0IlJeb1RuKp3Ba5WQkfeg== X-CSE-MsgGUID: qc2eVGGgSumNL0Ypn7dCFQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="41480155" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="41480155" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2024 22:53:21 -0800 X-CSE-ConnectionGUID: 1XXbX736Q1mDeYZ4StxVJA== X-CSE-MsgGUID: db0bZxxQTYSEd+gxBGf0nA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,137,1728975600"; d="scan'208";a="84941762" Received: from shliclel4217.sh.intel.com ([10.239.240.127]) by fmviesa006.fm.intel.com with ESMTP; 07 Nov 2024 22:53:20 -0800 From: "Hu, Lin1" To: gcc-patches@gcc.gnu.org Cc: hongtao.liu@intel.com, ubizjak@gmail.com, hjl.tools@gmail.com Subject: [PATCH v2] i386: Zero extend 32-bit address to 64-bit with option -mx32 -maddress-mode=long. [PR 117418] Date: Fri, 8 Nov 2024 14:53:19 +0800 Message-Id: <20241108065319.3012078-1-lin1.hu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Thanks for your suggestions and answer. This is the current version. There is no problem in my test environment, but also in the further testing, sent for review. BRs, Lin -maddress-mode=long let Pmode = DI_mode, so zero extend 32-bit address to 64-bit and uses a 64-bit register as a pointer for avoid raise an ICE. gcc/ChangeLog: PR target/117418 * config/i386/i386-expand.cc (ix86_expand_builtin): Convert pointer's mode according to Pmode. gcc/testsuite/ChangeLog: PR target/117418 * gcc.target/i386/pr117418-1.c: New test. --- gcc/config/i386/i386-expand.cc | 12 +++++++++++ gcc/testsuite/gcc.target/i386/pr117418-1.c | 23 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr117418-1.c diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 6eef27f3fcd..a99ef9613f5 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -14064,6 +14064,9 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, op1 = expand_normal (arg1); op2 = expand_normal (arg2); + if (GET_MODE (op1) != Pmode) + op1 = convert_to_mode (Pmode, op1, 1); + if (!address_operand (op2, VOIDmode)) { op2 = convert_memory_address (Pmode, op2); @@ -14099,6 +14102,9 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, emit_label (ok_label); emit_insn (gen_rtx_SET (target, pat)); + if (GET_MODE (op0) != Pmode) + op0 = convert_to_mode (Pmode, op0, 1); + for (i = 0; i < 8; i++) { op = gen_rtx_MEM (V2DImode, @@ -14123,6 +14129,9 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, if (!REG_P (op0)) op0 = copy_to_mode_reg (SImode, op0); + if (GET_MODE (op2) != Pmode) + op2 = convert_to_mode (Pmode, op2, 1); + op = gen_rtx_REG (V2DImode, GET_SSE_REGNO (0)); emit_move_insn (op, op1); @@ -14160,6 +14169,9 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, if (!REG_P (op0)) op0 = copy_to_mode_reg (SImode, op0); + if (GET_MODE (op3) != Pmode) + op3 = convert_to_mode (Pmode, op3, 1); + /* Force to use xmm0, xmm1 for keylow, keyhi*/ op = gen_rtx_REG (V2DImode, GET_SSE_REGNO (0)); emit_move_insn (op, op1); diff --git a/gcc/testsuite/gcc.target/i386/pr117418-1.c b/gcc/testsuite/gcc.target/i386/pr117418-1.c new file mode 100644 index 00000000000..0eb48401c96 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr117418-1.c @@ -0,0 +1,23 @@ +/* PR target/117418 */ +/* { dg-do compile } */ +/* { dg-options "-maddress-mode=long -mwidekl -mx32" } */ +/* { dg-final { scan-assembler-times "aesdec128kl" 1 } } */ +/* { dg-final { scan-assembler-times "aesdec256kl" 1 } } */ +/* { dg-final { scan-assembler-times "aesenc128kl" 1 } } */ +/* { dg-final { scan-assembler-times "aesenc256kl" 1 } } */ +/* { dg-final { scan-assembler-times "encodekey128" 1 } } */ +/* { dg-final { scan-assembler-times "encodekey256" 1 } } */ + +typedef __attribute__((__vector_size__(16))) long long V; +V a; + +void +foo() +{ + __builtin_ia32_aesdec128kl_u8 (&a, a, &a); + __builtin_ia32_aesdec256kl_u8 (&a, a, &a); + __builtin_ia32_aesenc128kl_u8 (&a, a, &a); + __builtin_ia32_aesenc256kl_u8 (&a, a, &a); + __builtin_ia32_encodekey128_u32 (0, a, &a); + __builtin_ia32_encodekey256_u32 (0, a, a, &a); +}