From patchwork Tue Aug 8 21:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 132884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2410475vqr; Tue, 8 Aug 2023 14:40:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRpSCSbox0bztKddK9O5PQhBM9AUU5X3YOppLq/F/iWT5IoTxq9dlHPgf33eCrNotDN55z X-Received: by 2002:a17:906:3117:b0:99b:bc51:8ca3 with SMTP id 23-20020a170906311700b0099bbc518ca3mr646880ejx.1.1691530847184; Tue, 08 Aug 2023 14:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691530847; cv=none; d=google.com; s=arc-20160816; b=V8Rz/LZdiql8nVZNuzYDjOTco65JcvupahDO867ZS/2XxJolRhPWTUmIJYdJQU6uP/ Ea0cV5YS5Mapgqi5urInRjQSgFiJERLl8cXs2HQCKrxO9Gv6AgtkQwNEtOsq6WEao9J5 zycS3WEurM989WcWy+jZsebYdDzm5y+D6b5eccZ6SdOmwDBoK6hJ8vcAXjJIMU9CDydI 9WsXtxZd9dTklI9mnX7epXj8O6f0141C8g1hTCvFCoHVAJq/SxDHs69ef+y4F9tgn8wg mI2oSWzlK8MpBW8NONB3O5Z4ZbnOb+E36qAutp0jRdw/L7iWI4WGRjvVZeCN5oG/uj4I x2kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:from :content-language:user-agent:mime-version:date:message-id :dkim-signature:dmarc-filter:delivered-to; bh=eSkmZ1WhwC8PB1c4pWHgevHS71qX1MqMPKHAfhR7V70=; fh=uUC8+KP4ElhOu9Eyg7Oa7GcHJM0dHBYX7XgTY3wzyXg=; b=bRxF9+wxwHMEDwMwd9vr6Kb78PGkSn2Aw2ckSpNBN9Td+0QDMhACYkDN6ftzw6xu6Y KnI3Cyjn8idfmwut+N1aVC1aFLQm/CcI0E6reaezqVpLjy+yANRmLhp91h/KDGXxfW+s sesRxXkTSiSR4TmjDmIXddZ4zgHJdbngDFVOveS5OocqgmangHcTi27YOTEZZLb/kbJa E23rN/guHP0/tRn19qFLVUVaH+/bT0c9Vv37Gh9XrxxmJQ4PogBQRsVDOG9GmHQ7oHwB xfi3BThhVU5PH+v9noPIiTa1YgUkJsjC9atu+GoJISNHUP4RsmvbsfS8fcn4JDRKPUKO Ksfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=AIacMkgR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k2-20020a1709063e0200b00992aea2c6a6si7541066eji.977.2023.08.08.14.40.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 14:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=AIacMkgR; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D313A3858033 for ; Tue, 8 Aug 2023 21:40:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id DE7E9385842D for ; Tue, 8 Aug 2023 21:40:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE7E9385842D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bc7e65ea44so2193775ad.1 for ; Tue, 08 Aug 2023 14:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1691530809; x=1692135609; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=eSkmZ1WhwC8PB1c4pWHgevHS71qX1MqMPKHAfhR7V70=; b=AIacMkgR+DhFGzQwSpgUgjs5wsCE9FkXJQfdZWz9SlzbOR8p3vMlZTNLd5uYxtqAFx SNG3gb0Kq/dewtdVxXYbt/td3ur2DeEeLYKB2+qVhDrSvtD3W4hR12cP1sk3aADoxuVu ODyeASKRN20gcWApsrYObsEIOjIJwf9dgkIpclk4klTwdZ5AxWlxkgZiwyKrKULjJ1lC jA6LK7oQeJNoifw/X9uKV+UfGzsRKUEIZr6P7oqQ3UVGyydsO5auplVoQJkMfinlyGA4 nCShpjvuwy1/Mx72LfDKzNtWb8v06o3aGkPqztFfl2ijGx0c47VgktFTesZ28Vv2+0m2 JFyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691530809; x=1692135609; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eSkmZ1WhwC8PB1c4pWHgevHS71qX1MqMPKHAfhR7V70=; b=Wudwe1DhwMamqvWdyHaKsUjUwhpN5cqdp9Ifqxl3wwScc/+snP596ohAIZ6wJJTNKP xXJUO0OTXhQNhSc2QQe+DHBPiDOJsVOFKi0IraOJiKNFch8VWBPRS4NZj08unO5ZzJDb g9yGySlCOC4LW+rUMgoiFZeGYcEPm9yM8cWwg9AI2AMmW4fhdbWWrJe9L/oP6F6CYYcu Skc3ZX0UZFRROAGdFugUVDI6td0IcRI5oKauBxNReX/kujD05eCQaFNEBaqfo3AiGYP/ 8lAbHCStHV5r60lK7ZnyOuOscJBCUfMLJ5axcdumdSmQsPWubG01H+rpBX462hd02n0t 769Q== X-Gm-Message-State: AOJu0Yzk9tpUtDJgUVwOLaZhFE860x/C1pem/vI0k3H6q8rwZBzzTM35 SivOAdAmd/B4stppHiX0V67/bOyTY5lcEgBYZ4Kdag== X-Received: by 2002:a17:903:494:b0:1bc:7001:6e69 with SMTP id jj20-20020a170903049400b001bc70016e69mr1027522plb.23.1691530809230; Tue, 08 Aug 2023 14:40:09 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id q16-20020a170902dad000b001adf6b21c77sm9501803plx.107.2023.08.08.14.40.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Aug 2023 14:40:08 -0700 (PDT) Message-ID: Date: Tue, 8 Aug 2023 15:40:07 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US From: Jeff Law Subject: [committed] [RISC-V] Fix bug in condition canonicalization for zicond To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773698649210656964 X-GMAIL-MSGID: 1773698649210656964 Vineet's glibc build triggered an ICE building glibc with the latest zicond bits. It's a minor issue in the canonicalization of the condition. When we need to canonicalize the condition we use an SCC insn to handle the primary comparison with the output going into a temporary with the final value of 0/1 which we can then use in a zicond instruction. The mode of the newly generated temporary was taken from mode of the final destination. That's simply wrong. The mode of the condition needs to be word_mode. This patch fixes that minor problem and adds a suitable testcase. Committed to the trunk, Jeff commit 20659be04c2749f9f47b085f1789eee0d145fb36 Author: Jeff Law Date: Tue Aug 8 15:32:38 2023 -0600 [committed] [RISC-V] Fix bug in condition canonicalization for zicond Vineet's glibc build triggered an ICE building glibc with the latest zicond bits. It's a minor issue in the canonicalization of the condition. When we need to canonicalize the condition we use an SCC insn to handle the primary comparison with the output going into a temporary with the final value of 0/1 which we can then use in a zicond instruction. The mode of the newly generated temporary was taken from mode of the final destination. That's simply wrong. The mode of the condition needs to be word_mode. This patch fixes that minor problem and adds a suitable testcase. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Use word_mode for the temporary when canonicalizing the condition. gcc/testsuite * gcc.target/riscv/zicond-ice-1.c: New test. diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index f9b53d21d1b..e277c138636 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -3600,7 +3600,7 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt) /* Emit an scc like instruction into a temporary so that we can use an EQ/NE comparison. */ - rtx tmp = gen_reg_rtx (mode); + rtx tmp = gen_reg_rtx (word_mode); /* We can support both FP and integer conditional moves. */ if (INTEGRAL_MODE_P (GET_MODE (XEXP (op, 0)))) diff --git a/gcc/testsuite/gcc.target/riscv/zicond-ice-1.c b/gcc/testsuite/gcc.target/riscv/zicond-ice-1.c new file mode 100644 index 00000000000..d1f98a42582 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zicond-ice-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ + +int a, c; +long b; + +void +d() { + for (;;) + if (a & (b < 8 ?: 1 << b)) + c = 1; +}