From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 065823857C63 for ; Sun, 19 Nov 2023 05:53:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 065823857C63 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 065823857C63 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700373237; cv=none; b=N6el8Qg5gZDUuBQF441+gBuC9wrPkMCkWIvhUI53kauVEV840O2kkGchpiZUWUnPbTV6yENRTZqCofunVC1fwduI3i5H0Ab/Z3RXffWXIGy5E7pokWLeZxfJSINIURPujqMY56PpuJxJv6DbctMRYtdNhWAcsfW5osmnhiItknc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700373237; c=relaxed/simple; bh=fj0J5K0bMEaBtj0BwQnR8q51kk1e500g7XTlhFACu5M=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=aT1ZuRkc0wlMOePPOmkXrEYXjVt+YiphoCd4QNXRAUNrRzxHc4d8MkX+DprAL3wQRviBDkj5CVnczi0tIySB7PE0ji38UQf/9R8wrpHiqVE7uRPqB9NYv8lOJe1oR/gefywnR58vpcu8MqYhghnIYxO+TIsR1s9anYV9HOrDXMM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-543456dbd7bso8518977a12.1 for ; Sat, 18 Nov 2023 21:53:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700373235; x=1700978035; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WXR1xWWSYHLjXaU0j2J0cXXczKYEhOJZhR+cjiaV2fE=; b=LDnG7bCaWfy1W4TIbxY7rccv+BLCK5LAJqzfU7Aahup8OBMXzkAIsADi9j3ZyBkbvB tt+sCQ+1hJJNtCq2dD/JCe36PIxpvMJc25VepzyXfcXOHz01v+cul9UtGDEZGTorZMT8 L4l/ERibG+wEAJYqgA77YiDYDTTqewl6ulEC438XrQAvPsRPBRwvZUcrlUuA1KcyPG68 nJEBPvZryUg6/9/FzirNnikrBsUVzhpfyuxADZdXuduJ6rq3Dr+ojmIlvchmqHXi+cQZ tb+y0kFpGPUkSrwsEohHmj3bWEJbtZpfGFMSZPlmdZqxBbNHdolIN0kJn/qwk6MAwXRe I3CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700373235; x=1700978035; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WXR1xWWSYHLjXaU0j2J0cXXczKYEhOJZhR+cjiaV2fE=; b=BmuB7KfVgloxtshRzu+rclgITp2QZMTE1UYP6n4Zo7dvfrdIvMG63LlKskBxfY1H5y 8qT89zWlaxCqRGrHaeBcXClTw+VjKRj4GD/iApceUXa831wD/ptHokbquMGlF02UQspX 79erneufeQZS2H/aHse2uxlUkziUW+XCqx+bLDJS2xxQO329IOVz0QbqJuR4q0VAmYYY url3qpK72PqQR0mJsAU5p69Tra/d0FHtcaWfPvwbr7+I8w5fYfmMLJEToiuu7wn+HVE+ ydHwW6VDvjAHLkgKfgjty22niUsNqO8ewhLW59bFGjirL6btIFZL6yaukBysHFC5zXjq HNlQ== X-Gm-Message-State: AOJu0YxJoA7J3eul9dALzltNJknu1N/tqAGeumvwOVP0RfroBYpJz11o 1ruT1qv4zXch9oVOPR4fHQKGO8y8Sk4Hl3aeqH4= X-Google-Smtp-Source: AGHT+IFCfVpBgoKJojRFA5JlLun/9Wcf8uIl5G8UjQbCfhNyxTi7Ff5qsz7rjnDgj6S0a9sntgMc0Qjqd4HDId05Nis= X-Received: by 2002:a17:906:158:b0:9e8:2441:5cd4 with SMTP id 24-20020a170906015800b009e824415cd4mr3252264ejh.17.1700373234448; Sat, 18 Nov 2023 21:53:54 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kito Cheng Date: Sun, 19 Nov 2023 13:53:41 +0800 Message-ID: Subject: Re: [PATCH 04/44] RISC-V: Sanitise NEED_EQ_NE_P case with `riscv_emit_int_compare' To: "Maciej W. Rozycki" Cc: gcc-patches@gcc.gnu.org, Andrew Waterman , Jim Wilson , Palmer Dabbelt Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: LGTM On Sun, Nov 19, 2023 at 1:36=E2=80=AFPM Maciej W. Rozycki wrote: > > For the NEED_EQ_NE_P `riscv_emit_int_compare' is documented to only emit > EQ or NE comparisons against zero, however it does not catch incorrect > use where a non-equality comparison has been requested and falls through > to the general case then. Add a safety guard to catch such a case then. > > Arguably the NEED_EQ_NE_P case would best be moved into a function of > its own, but let's leave it for a separate cleanup. > > gcc/ > * config/riscv/riscv.cc (riscv_emit_int_compare): Bail out if > NEED_EQ_NE_P but the comparison is neither EQ nor NE. > --- > FWIW the structure of code here clearly shows the NEED_EQ_NE_P case has > been bolted on as an afterthought rather than how this piece would look > if written from scratch right away. Let's defer any further cleanups at > this stage of the development cycle though. > --- > gcc/config/riscv/riscv.cc | 1 + > 1 file changed, 1 insertion(+) > > gcc-riscv-emit-int-compare-need-eq-ne.diff > Index: gcc/gcc/config/riscv/riscv.cc > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc.orig/gcc/config/riscv/riscv.cc > +++ gcc/gcc/config/riscv/riscv.cc > @@ -3779,6 +3779,7 @@ riscv_emit_int_compare (enum rtx_code *c > *op1 =3D const0_rtx; > return; > } > + gcc_unreachable (); > } > > if (splittable_const_int_operand (*op1, VOIDmode))