From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mxout.security-mail.net (mxout.security-mail.net [85.31.212.42]) by sourceware.org (Postfix) with ESMTPS id 04FFA3856DC2 for ; Tue, 12 Sep 2023 10:07:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04FFA3856DC2 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=kalrayinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kalrayinc.com Received: from localhost (localhost [127.0.0.1]) by fx302.security-mail.net (Postfix) with ESMTP id 4E6714F7E53 for ; Tue, 12 Sep 2023 12:07:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1694513276; bh=giAB6lO9tk0JJlN74o6LB92qMTL06xF1aFuSyPzEcfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HvolYiY9oRh7e1TcVDoIKyWvT8rqtGQ4pinjLns1WHHNhbCncJRo0ek0gK3PQYjBB j/CaUtR1ljONqBBIfP/uy7tVeqcUbPpLSQJ9cXturJZlCE/fBM6Qat0BvVXjv/SStI n/+TwbbLs4mtZ5oMUY4Avj1AYJSz5hAJFhF2qnao= Received: from fx302 (localhost [127.0.0.1]) by fx302.security-mail.net (Postfix) with ESMTP id 304E54F814D for ; Tue, 12 Sep 2023 12:07:56 +0200 (CEST) Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-mr2fra01on0101.outbound.protection.outlook.com [104.47.25.101]) by fx302.security-mail.net (Postfix) with ESMTPS id AE8DC4F838E for ; Tue, 12 Sep 2023 12:07:55 +0200 (CEST) Received: from PR1P264MB3448.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:184::6) by MRZP264MB2442.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Tue, 12 Sep 2023 10:07:51 +0000 Received: from PR1P264MB3448.FRAP264.PROD.OUTLOOK.COM ([fe80::ad9:f173:8a66:3461]) by PR1P264MB3448.FRAP264.PROD.OUTLOOK.COM ([fe80::ad9:f173:8a66:3461%7]) with mapi id 15.20.6768.029; Tue, 12 Sep 2023 10:07:51 +0000 X-Virus-Scanned: E-securemail Secumail-id: <7499.6500387b.adbb6.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkJKJmBf4qQOamuJVDSiG5o0OJxVN0WyADaVTKA4NSjNn0L+U1Q6LA1f93STuIeaZnW+1Axmb3KcBSYBA1dl7CUWKNFRF6bx0vioMbw8SCaNdmW+SatRdDe8k8p8+zBosFUbu80IHQstLtq0hFlp3+GG9PYpihgnvZAHYTTt8XlboOqymiVJYhXQMlXIQx4ZXst8fVQoZFOiqk0xqwJgP5AY+Clx9NQgXaelc6MFaN18uWhflHrWaT5ZzgXGvobp2959eT5+C+N1yolt0Vn6mIp7E4NLtcnilaH7qDlK3mjshxzqziwFt350odQo360ydx7RAR6DRAfzHJOzYYFPQQ== 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=dzlyu9afTXKq7MvxK9SCuxhpfgU4Qj7y2H6Qa5rLGgg=; b=eI1ob48puMeiSjqU1w8pqMct1XFjMEZLtC6uQGst6/iT7My6rBkQAbrqLSMHj6Icx15yDirf+5iMzRxyHeMf6kpTjMLPQ85J0th3R8BR4Ftofct6VSpFpFPIYDSAv/43u/pNZ+hivxYDYap7Mph8HIYuWwePOThV/C2Z3KEH7o3bY1OVo0RQYpktQkoBV0xq9ck4ypGze+ySOoh+M8wNO+fBGvuo9RcsiSR1JtVW3Nyqscll51vfqbljA+qGkibN4r6o/RzJ3SG0aaAOLR7B97NHfcP58UEC1ByT02jN5pLxZaq9V19j1JjACH9Wl+HLawYiUAFLbCqMRq+/pq2bTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kalrayinc.com; dmarc=pass action=none header.from=kalrayinc.com; dkim=pass header.d=kalrayinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dzlyu9afTXKq7MvxK9SCuxhpfgU4Qj7y2H6Qa5rLGgg=; b=L2bcjJ1+z9QHHJUvM8sjNqpT8XurBxtROtLbP026hhgmlA26nXcKRVTGaFB8A2YnKDDnT0373hUFOhmwbETNskFOyJzEJjXrXDUra+bHqUH+52rRfVMa1npmfuXXQd6jgdULHXSjynx6tlKZw9yiQxQmCSEqcsMgRQ7hch3RLK9o4Ir3Vi2Y4BtrZJpJG0RxQwosHECsmpxFo+p5MEcl050c/h58/zxgw1JG7bB1qAwJKQpwz9NafCm8lITl65t0RW7NDqAK2T+2jUhpljFOkM7ZkLxxm+dJeZfPsICp0DxRVEz173tnNNXggsa4Xr5u194l2KXDb5cIDh55cDuXKQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kalrayinc.com; From: Sylvain Noiry To: gcc-patches@gcc.gnu.org Cc: Sylvain Noiry Subject: [PATCH v2 04/11] Native complex ops: Allow native complex regs and ops in rtl Date: Tue, 12 Sep 2023 12:07:06 +0200 Message-ID: <20230912100713.1074-5-snoiry@kalrayinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230912100713.1074-1-snoiry@kalrayinc.com> References: <20230717090250.4645-10-snoiry@kalrayinc.com> <20230912100713.1074-1-snoiry@kalrayinc.com> X-ClientProxiedBy: LO2P265CA0286.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a1::34) To PR1P264MB3448.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:184::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PR1P264MB3448:EE_|MRZP264MB2442:EE_ X-MS-Office365-Filtering-Correlation-Id: 1001f79e-ce30-4ec2-6f16-08dbb3781ff9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eQiXkPCK38s2fB4LjGg2upc+bTUlBwN4QXtV24SUpplYDPs2jyJwonGLSWcQCpZ/RzLbCMYxsUY33lKzRDvdV/NWwbSjLLzUgdfTQf05iUTKC3pL1p5OZAQ8J8R1NwGLfoSKzLoKhd3k8+K0avOeozPnP6788XdUVE6SnmfhKEi1L+riRjOmNE4FSGUCJPaOPZAgMIv8zsBKlqQX4IuKHofVE36owSJt8s5n8uB3pSg/0/f8aknnk6re9Qkhrj6N3OzBE63minOtMC4nYH8B+yHjRJ+CjouVOFDAKZLrqeX33qzNBclPxtr8xkm3LWM34zSWE98R2ezNLparvViEeFepxBMkcenfYSvGL6+o7Z8SCyFJl8NeGtd9iOQt4UzKQ0SkRUqRhCdi/wQIdMFf8rHlFAlP6DWkintsZan5fX67YT8SjJ2VzoPCVc53RGai/XeOeLrj+Rswgp99LuExCft8nTmqLk+CwuEP8jeQ65Gv6K45GXG5nUz/ghf4HECgmkgpXHPQH4xOjxnd0+Ny34RNWJOvOs8U2U/iMMzcZbk2/YT0TydJG6rw3Ech+RRT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PR1P264MB3448.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(376002)(346002)(396003)(39860400002)(451199024)(186009)(1800799009)(1076003)(107886003)(2616005)(5660300002)(4326008)(8936002)(8676002)(6512007)(26005)(6486002)(6666004)(6506007)(83380400001)(66476007)(66556008)(66946007)(38100700002)(478600001)(41300700001)(6916009)(316002)(36756003)(86362001)(30864003)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A2A0LOOb4oXEb63SNJ42NaCdQag1/l723KNuYMXM5kc8ZYIlEWbXkfy5DifPNtKkPjdBzGb0HncReJK6pGN915iVKdQ5jt0K9ZsGmHEzx/P391ee8WBi01tXEff2tMGAy8rQjOtnXz6gCK0U1i7uAzHTvHII9DRVhJe2dP9AAI8NP1FSlN8PfWCglwpINMo3SJT6dQVIgWfFl7tgZmG7GY3IWyB6Lm3ysXr0uvyWtF9Ghu48ynPrljoyxWzoCEQAGTw9iZBiEZcVBPf+/AXW9Q6FHE2b+V3pZEHSijXsSrLMdeQuC4UdEEKpGELet+IcPURH+TSI1DFt6uF28iCkKKwqQbwBAIa31mlqRIUzfrgYMXah6/SERjomZYYI3T7H+vwHFKl6peUTZ3JJQzKRgZZ/Rs1j3wlgNJcxtms58drCnXkjRUmVfe5gNtiFL9JBJHZojygJlmmWNNcJ5qqOwyekcf0LkNFK7RdKikaO45VHlV1HZMWKOWc8PIyHL08w/Fezl7aIA1CpUiVYk7SCzBFwNTNelTADDRowTXaRHpIoQzxm7KNgtXB1CioL66+jhhTx4kaRX3wrm6grJnSh5XCAUO8ezqBfzURWQ7/13hsoTRP2CQ82rpm6OY4DtIw6rvA6MMcrw0xpppicfe0vALhpstmvQESILTk3h1fjtEFdYPHlBUxOGd+A4b4yigup46bUSaxktsTX/QYsU46v00Xo+lfHL8i1iKbVRFRuiKZrLs39E+D0rABzhlTHU0z5PX+Zjw+tkj7ZXsHzEyKLLcGiilX35ZyyP2PshixPj98XnTQQFFDvPVrCoK3o/qLGJaD8Hw49PP8BhNVWH43R1Yjq63JfSd25GBSdM4iB67cLDRmTeWbBLPrs/SV1F4a91udxdkqGXSnOYiGHNMp77ooKF+LTfWZNUa+Od7fACR+aKUEUN5OCluFOX6pbytye kw62KshhdsJARjDNYqfADMX1Uwb6tcEIwk+XC7UmqlNkGHegTcSYUJmkqmcsChB5+PdoYmYo8UUF1EHVqudv/w5sz7T7ByRXKLI/XAX3PHW1wjmLH2tcGCtAnUMHTeb8p4ls+1hujM0TIgk5rZ13F7I8saWJBS9vbOoiXEyaRLJX7tSZDEbyaS6mwe8WmOCFMuIvvdsr8vJRFCJj3ttqG81D3aJ1StciaYPoTKeI1xH0xOk7cQ8tPGQdIDSwvN4de+jk3e6Y6Jk7LITgLZ+RFVEUrqGA19RWRPVEg6QKGDqxRhmWfbleBG6000i90qARhUaDHKcgKB1hy9QRGbu6ZVmEXw7OcQsd4UQIi/eW73yoHdlowy4TXH78Te/TvLnAgOKAvw6s9KGfTkp4wE9G4zkSTggj8gsg2/psomCu6395eZ4j6J3ynqnc9sAJUIhPtHUwwQQuP652AQSFwGiJzYVmMMzRz9t8P/+N90oo0SByzzoFpKwPw5km2lggzb+Q34Bfht/UrKZVesgVLHa1IwYd9bBkZcR9dnsVEKUqq/agMOCgyqgNx8F/6rvaANkxGB06dYMZVvRgd5kDWXLUKtoF7yKwy8XSazC6JsF1IVzsYYL+WyFPGWTp4Sbgc11XkBmRdZTCcJS2QAG+XZBMzQ== X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1001f79e-ce30-4ec2-6f16-08dbb3781ff9 X-MS-Exchange-CrossTenant-AuthSource: PR1P264MB3448.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 10:07:51.7908 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8931925d-7620-4a64-b7fe-20afd86363d3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 68PhaLT92+YcYhq24JVkt07LxKJ/t+DqpBLUwRN59yn9/eUijboBZd5i1lFZiD4RLX4RBaUtWyHqO/Y6TY3mIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB2442 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-ALTERMIMEV2_out: done X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,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 List-Id: Summary: Support registers of complex types in rtl. Also adapt the functions called during the expand pass to support native complex operations. gcc/ChangeLog: * explow.cc (trunc_int_for_mode): Allow complex int modes * expr.cc (emit_move_complex_parts): Move both parts at the same time if it is supported by the backend (emit_move_complex): Do not move via integer if not int mode corresponds. For complex floats, relax the constraint on the number of registers for targets with pairs of registers, and use native moves if it is supported by the backend. (expand_expr_real_2): Move both parts at the same time if it is supported by the backend (expand_expr_real_1): Update the expand of complex constants (const_vector_from_tree): Add the expand of both parts of a complex constant * real.h: update FLOAT_MODE_FORMAT * machmode.h: Add COMPLEX_INT_MODE_P and COMPLEX_FLOAT_MODE_P predicates * optabs-libfuncs.cc (gen_int_libfunc): Add support for complex modes (gen_intv_fp_libfunc): Likewise * recog.cc (general_operand): Likewise * cse.cc (try_const_anchors): Likewise * emit-rtl.cc: (validate_subreg): Likewise --- gcc/cse.cc | 2 +- gcc/doc/tm.texi | 2 +- gcc/emit-rtl.cc | 2 +- gcc/explow.cc | 2 +- gcc/expr.cc | 70 ++++++++++++++++++++++++++++++++++------ gcc/internal-fn.cc | 4 +-- gcc/machmode.h | 8 +++++ gcc/optabs-libfuncs.cc | 25 ++++++++++---- gcc/real.h | 3 +- gcc/recog.cc | 1 + gcc/target.def | 2 +- gcc/targhooks.cc | 8 ++--- gcc/targhooks.h | 3 +- gcc/tree-ssa-forwprop.cc | 1 + 14 files changed, 105 insertions(+), 28 deletions(-) diff --git a/gcc/cse.cc b/gcc/cse.cc index c46870059e6..5ce6c692070 100644 --- a/gcc/cse.cc +++ b/gcc/cse.cc @@ -1313,7 +1313,7 @@ try_const_anchors (rtx src_const, machine_mode mode) unsigned lower_old, upper_old; /* CONST_INT may be in various modes, avoid non-scalar-int mode. */ - if (!SCALAR_INT_MODE_P (mode)) + if (!(SCALAR_INT_MODE_P (mode) || COMPLEX_INT_MODE_P (mode))) return NULL_RTX; if (!compute_const_anchors (src_const, &lower_base, &lower_offs, diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 470497a3ade..1e87f798449 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4631,7 +4631,7 @@ This hook should return the rtx representing the specified @var{part} of the com @var{part} can be the real part, the imaginary part, or both of them. @end deftypefn -@deftypefn {Target Hook} void TARGET_WRITE_COMPLEX_PART (rtx @var{cplx}, rtx @var{val}, complex_part_t @var{part}) +@deftypefn {Target Hook} void TARGET_WRITE_COMPLEX_PART (rtx @var{cplx}, rtx @var{val}, complex_part_t @var{part}, bool @var{undefined_p}) This hook should move the rtx value given by @var{val} to the specified @var{var} of the complex given by @var{cplx}. @var{var} can be the real part, the imaginary part, or both of them. @end deftypefn diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc index 22012bfea13..f7c33c4afb1 100644 --- a/gcc/emit-rtl.cc +++ b/gcc/emit-rtl.cc @@ -946,7 +946,7 @@ validate_subreg (machine_mode omode, machine_mode imode, if this ought to be represented at all -- why can't this all be hidden in post-reload splitters that make arbitrarily mode changes to the registers themselves. */ - else if (VECTOR_MODE_P (omode) + else if ((VECTOR_MODE_P (omode) || COMPLEX_MODE_P (omode)) && GET_MODE_INNER (omode) == GET_MODE_INNER (imode)) ; /* Subregs involving floating point modes are not allowed to diff --git a/gcc/explow.cc b/gcc/explow.cc index 6424c0802f0..48572a40eab 100644 --- a/gcc/explow.cc +++ b/gcc/explow.cc @@ -56,7 +56,7 @@ trunc_int_for_mode (HOST_WIDE_INT c, machine_mode mode) int width = GET_MODE_PRECISION (smode); /* You want to truncate to a _what_? */ - gcc_assert (SCALAR_INT_MODE_P (mode)); + gcc_assert (SCALAR_INT_MODE_P (mode) || COMPLEX_INT_MODE_P (mode)); /* Canonicalize BImode to 0 and STORE_FLAG_VALUE. */ if (smode == BImode) diff --git a/gcc/expr.cc b/gcc/expr.cc index 12b74273144..01462486631 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -3842,8 +3842,14 @@ emit_move_complex_parts (rtx x, rtx y) && REG_P (x) && !reg_overlap_mentioned_p (x, y)) emit_clobber (x); - write_complex_part (x, read_complex_part (y, REAL_P), REAL_P, true); - write_complex_part (x, read_complex_part (y, IMAG_P), IMAG_P, false); + machine_mode mode = GET_MODE (x); + if (optab_handler (mov_optab, mode) != CODE_FOR_nothing) + write_complex_part (x, read_complex_part (y, BOTH_P), BOTH_P, true); + else + { + write_complex_part (x, read_complex_part (y, REAL_P), REAL_P, true); + write_complex_part (x, read_complex_part (y, IMAG_P), IMAG_P, false); + } return get_last_insn (); } @@ -3863,14 +3869,14 @@ emit_move_complex (machine_mode mode, rtx x, rtx y) /* See if we can coerce the target into moving both values at once, except for floating point where we favor moving as parts if this is easy. */ - if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT + scalar_int_mode imode; + if (!int_mode_for_mode (mode).exists (&imode)) + try_int = false; + else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT && optab_handler (mov_optab, GET_MODE_INNER (mode)) != CODE_FOR_nothing - && !(REG_P (x) - && HARD_REGISTER_P (x) - && REG_NREGS (x) == 1) - && !(REG_P (y) - && HARD_REGISTER_P (y) - && REG_NREGS (y) == 1)) + && optab_handler (mov_optab, mode) != CODE_FOR_nothing + && !(REG_P (x) && HARD_REGISTER_P (x)) + && !(REG_P (y) && HARD_REGISTER_P (y))) try_int = false; /* Not possible if the values are inherently not adjacent. */ else if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT) @@ -11044,6 +11050,48 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, return original_target; } + else if (original_target && (GET_CODE (original_target) == REG) + && + ((GET_MODE_CLASS (GET_MODE (original_target)) == + MODE_COMPLEX_INT) + || (GET_MODE_CLASS (GET_MODE (original_target)) == + MODE_COMPLEX_FLOAT))) + { + mode = TYPE_MODE (TREE_TYPE (exp)); + + /* Move both parts at the same time if it is possible. */ + if (TREE_COMPLEX_BOTH_PARTS (exp) != NULL) + { + op0 = expand_expr (TREE_COMPLEX_BOTH_PARTS (exp), + original_target, mode, EXPAND_NORMAL); + write_complex_part (original_target, op0, BOTH_P, false); + } + else + { + mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp))); + + rtx rtarg = gen_reg_rtx (mode); + rtx itarg = gen_reg_rtx (mode); + op0 = + expand_expr (TREE_REALPART (exp), rtarg, mode, EXPAND_NORMAL); + op1 = + expand_expr (TREE_IMAGPART (exp), itarg, mode, EXPAND_NORMAL); + + write_complex_part (original_target, op0, REAL_P, true); + write_complex_part (original_target, op1, IMAG_P, false); + } + return original_target; + } + else if ((TREE_COMPLEX_BOTH_PARTS (exp) != NULL) + && (known_le (GET_MODE_BITSIZE (mode), 2 * BITS_PER_WORD))) + { + op0 = + expand_expr (TREE_COMPLEX_BOTH_PARTS (exp), original_target, mode, + EXPAND_NORMAL); + rtx tmp = gen_reg_rtx (mode); + write_complex_part (tmp, op0, BOTH_P, false); + return tmp; + } /* fall through */ @@ -13391,6 +13439,10 @@ const_vector_from_tree (tree exp) else if (TREE_CODE (elt) == FIXED_CST) builder.quick_push (CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt), inner)); + else if (TREE_CODE (elt) == COMPLEX_CST) + builder.quick_push (expand_expr + (TREE_COMPLEX_BOTH_PARTS (elt), NULL_RTX, mode, + EXPAND_NORMAL)); else builder.quick_push (immed_wide_int_const (wi::to_poly_wide (elt), inner)); diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index a01b7160303..c1c8e456320 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -2878,8 +2878,8 @@ expand_UADDC (internal_fn ifn, gcall *stmt) create_input_operand (&ops[3], op2, mode); create_input_operand (&ops[4], op3, mode); expand_insn (icode, 5, ops); - write_complex_part (target, re, false, false); - write_complex_part (target, im, true, false); + write_complex_part (target, re, REAL_P, false); + write_complex_part (target, im, IMAG_P, false); } /* Expand USUBC STMT. */ diff --git a/gcc/machmode.h b/gcc/machmode.h index a22df60dc20..fd87af7c74a 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -119,6 +119,14 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES]; || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \ || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT) +/* Nonzero if MODE is a complex integer mode. */ +#define COMPLEX_INT_MODE_P(MODE) \ + (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT) + +/* Nonzero if MODE is a complex floating-point mode. */ +#define COMPLEX_FLOAT_MODE_P(MODE) \ + (GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) + /* Nonzero if MODE is a complex mode. */ #define COMPLEX_MODE_P(MODE) \ (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ diff --git a/gcc/optabs-libfuncs.cc b/gcc/optabs-libfuncs.cc index f1abe6916d3..4bb56b2f0d5 100644 --- a/gcc/optabs-libfuncs.cc +++ b/gcc/optabs-libfuncs.cc @@ -190,19 +190,30 @@ gen_int_libfunc (optab optable, const char *opname, char suffix, int maxsize = 2 * BITS_PER_WORD; int minsize = BITS_PER_WORD; scalar_int_mode int_mode; + complex_mode cplx_int_mode; + int bitsize; - if (!is_int_mode (mode, &int_mode)) + if (is_int_mode (mode, &int_mode)) + bitsize = GET_MODE_BITSIZE (int_mode); + else if (is_complex_int_mode (mode, &cplx_int_mode)) + bitsize = GET_MODE_BITSIZE (cplx_int_mode); + else return; + if (maxsize < LONG_LONG_TYPE_SIZE) maxsize = LONG_LONG_TYPE_SIZE; if (minsize > INT_TYPE_SIZE && (trapv_binoptab_p (optable) || trapv_unoptab_p (optable))) minsize = INT_TYPE_SIZE; - if (GET_MODE_BITSIZE (int_mode) < minsize - || GET_MODE_BITSIZE (int_mode) > maxsize) + + if (bitsize < minsize || bitsize > maxsize) return; - gen_libfunc (optable, opname, suffix, int_mode); + + if (GET_MODE_CLASS (mode) == MODE_INT) + gen_libfunc (optable, opname, suffix, int_mode); + else + gen_libfunc (optable, opname, suffix, cplx_int_mode); } /* Like gen_libfunc, but verify that FP and set decimal prefix if needed. */ @@ -280,9 +291,11 @@ void gen_intv_fp_libfunc (optab optable, const char *name, char suffix, machine_mode mode) { - if (DECIMAL_FLOAT_MODE_P (mode) || GET_MODE_CLASS (mode) == MODE_FLOAT) + if (DECIMAL_FLOAT_MODE_P (mode) || GET_MODE_CLASS (mode) == MODE_FLOAT + || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) gen_fp_libfunc (optable, name, suffix, mode); - if (GET_MODE_CLASS (mode) == MODE_INT) + if (GET_MODE_CLASS (mode) == MODE_INT + || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT) { int len = strlen (name); char *v_name = XALLOCAVEC (char, len + 2); diff --git a/gcc/real.h b/gcc/real.h index 9ed6c372b14..53585418e68 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -189,7 +189,8 @@ extern const struct real_format * : (gcc_unreachable (), 0)]) #define FLOAT_MODE_FORMAT(MODE) \ - (REAL_MODE_FORMAT (as_a (GET_MODE_INNER (MODE)))) + (REAL_MODE_FORMAT (as_a \ + (GET_MODE_INNER ((COMPLEX_FLOAT_MODE_P (MODE)) ? (GET_MODE_INNER (MODE)) : (MODE))))) /* The following macro determines whether the floating point format is composite, i.e. may contain non-consecutive mantissa bits, in which diff --git a/gcc/recog.cc b/gcc/recog.cc index 92f151248a6..8f53e93f566 100644 --- a/gcc/recog.cc +++ b/gcc/recog.cc @@ -1441,6 +1441,7 @@ general_operand (rtx op, machine_mode mode) if the caller wants something floating. */ if (GET_MODE (op) == VOIDmode && mode != VOIDmode && GET_MODE_CLASS (mode) != MODE_INT + && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT) return false; diff --git a/gcc/target.def b/gcc/target.def index d63dacbbb8f..4eafff1d21b 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3338,7 +3338,7 @@ DEFHOOK "This hook should move the rtx value given by @var{val} to the specified @var{var} of the complex given by @var{cplx}.\n\ @var{var} can be the real part, the imaginary part, or both of them.", void, - (rtx cplx, rtx val, complex_part_t part), + (rtx cplx, rtx val, complex_part_t part, bool undefined_p), default_write_complex_part) /* Support for named address spaces. */ diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc index f6e7bc6c141..d89668cd1ab 100644 --- a/gcc/targhooks.cc +++ b/gcc/targhooks.cc @@ -1634,7 +1634,7 @@ default_read_complex_part (rtx cplx, complex_part_t part) BOTH_P, call recursively with REAL_P and IMAG_P. */ void -default_write_complex_part (rtx cplx, rtx val, complex_part_t part) +default_write_complex_part (rtx cplx, rtx val, complex_part_t part, bool undefined_p) { machine_mode cmode; scalar_mode imode; @@ -1642,8 +1642,8 @@ default_write_complex_part (rtx cplx, rtx val, complex_part_t part) if (part == BOTH_P) { - write_complex_part (cplx, read_complex_part (val, REAL_P), REAL_P); - write_complex_part (cplx, read_complex_part (val, IMAG_P), IMAG_P); + write_complex_part (cplx, read_complex_part (val, REAL_P), REAL_P, false); + write_complex_part (cplx, read_complex_part (val, IMAG_P), IMAG_P, false); return; } @@ -1696,7 +1696,7 @@ default_write_complex_part (rtx cplx, rtx val, complex_part_t part) } store_bit_field (cplx, ibitsize, (part == IMAG_P) ? ibitsize : 0, 0, 0, - imode, val, false); + imode, val, false, undefined_p); } /* By default do not split reductions further. */ diff --git a/gcc/targhooks.h b/gcc/targhooks.h index cf37eea24b5..f3ae17998de 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -128,7 +128,8 @@ extern rtx default_gen_rtx_complex (machine_mode mode, rtx real_part, rtx imag_part); extern rtx default_read_complex_part (rtx cplx, complex_part_t part); extern void default_write_complex_part (rtx cplx, rtx val, - complex_part_t part); + complex_part_t part, + bool undefined_p); /* OpenACC hooks. */ extern bool default_goacc_validate_dims (tree, int [], int, unsigned); diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 047f9237dd4..30e99f812f1 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3812,6 +3812,7 @@ pass_forwprop::execute (function *fun) } else gsi_next (&gsi); + gsi_next (&gsi); } else if (code == CONSTRUCTOR && VECTOR_TYPE_P (TREE_TYPE (rhs)) -- 2.17.1