From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id 3DDE53858D28 for ; Thu, 25 Jan 2024 00:57:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DDE53858D28 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 3DDE53858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706144240; cv=none; b=hzO4XpoEUFuyGcViOU1MU5FF78kN3d5//cTNqkmYQh4ew2RDbI2mUh2kk/QOf4sos5Pv3NCVT+90/X5Ict8atHQArvhzkEUe7YWpkWOaV4XF90pBarjwcyRSBb9d+HhFtdR/IMb1NLtv2w4HTuxAD0gHTYBqk1liXC1HE7b8cUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706144240; c=relaxed/simple; bh=0XTlTL3U5Ue/RRF6deYzCeLzRadVXGK6g3+j6tUJOOg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=tHGB0OK0UxDJUzx3oP6sk77Df2Cs2D6afK3IgfiX0bGU0+MknKJ/vy8Yiw7ghhdFOwupDA89jfweGzhMRwA3XEpt5SFWKfgaTfO98sWed7RyzzT/14mZHuCJXNvevqM16sruGzfFTLgviFfPF0U3MuVlRdFy2U7AeDtqgPR9n9Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7bf0f3bf331so287647639f.3 for ; Wed, 24 Jan 2024 16:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706144236; x=1706749036; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vk5C6AUIlissPz4DgeIcvq4LC/H2UZmjoAHC79dDSMw=; b=Jmlrgs85344cV+1mUDeIoyK87Wnxn8Bjk7OSbrpyHhuebERY2nnnpa7j4xkUMRYWOA 0f+OLa0vl8Xf9W9dwHKtjCoPFLBul1c2MPPEXgXookCKQnG2R4ZHxag99WvCf4D6ItYN ybPwqLsCJL1emNBL5hhG0sta6q37ASUVt+p5Vfor8hpzthleJfBP9aeadpqkZ28vnD45 DjIz711hdU4Rc2p+hiSzSd6H/SI/8iFAK5xjKFAq8DUJFdKzqn7OevsYw8s7Pn40oGmd xzkWwkfGEdzHduUianIuvsWdRldizLyW5PUHeXn+tPHkO+ITC2tU5l5A8Gl+GxFFby9a 9I5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706144236; x=1706749036; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vk5C6AUIlissPz4DgeIcvq4LC/H2UZmjoAHC79dDSMw=; b=xTThXi2xobAtRaUmfkcENSdPh6BvB+yR+rcl0Nb8ExmHQ+pebRZYpC/J5iJx4sN0LY +wOWMCiDO2YanVvsSecNtEw6ng8vMmnGUhocBplsyUYQGFqdLG52x6/we6ALU1MZzAHK pNLpNdb9PN6z7alSr4K+QkVvE88FCRHsQTp9E+ng/ve4pLbzm0kKr2otSHv4Jdezd4sk BPKsx/zpJO8Nz1k9JbWWJMQb/48rjg5v70cixgi2NUoK0i/2wOCdLUXnXfPeQFG1x3Ul 9ZfCof1quMZ3PjfKTUGojjmCvq5VEh6w81BNSseuhzYviXaDKN4CRbiPQvd39w6MMilg oNww== X-Gm-Message-State: AOJu0YwwRsrjIPQlFF+xDvI/THAAFJpn5/wYAQz+1/an42DR8TtRRf/9 Mxr6FGGUIg9b1Z7AoohN6wuJSpK2yvj6ZpD2Qfsq+t+jQbH8Uu1k X-Google-Smtp-Source: AGHT+IGBgHP1G4Lidvrfs2XE4YLtEmuRfSqObkpPoO2nNgmQiGPRYTshLyOfy/oybYFetJ/lSyjiwg== X-Received: by 2002:a5d:9f45:0:b0:7bf:9b4d:50a0 with SMTP id u5-20020a5d9f45000000b007bf9b4d50a0mr287412iot.40.1706144235859; Wed, 24 Jan 2024 16:57:15 -0800 (PST) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id x7-20020a056602160700b007bf0e4b4c63sm7708099iow.31.2024.01.24.16.57.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jan 2024 16:57:15 -0800 (PST) Message-ID: Date: Wed, 24 Jan 2024 17:57:14 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [middle-end PATCH take #2] Only call targetm.truly_noop_truncation for truncations. Content-Language: en-US To: Roger Sayle , gcc-patches@gcc.gnu.org References: <04d301da3c05$aadbb740$009325c0$@nextmovesoftware.com> From: Jeff Law In-Reply-To: <04d301da3c05$aadbb740$009325c0$@nextmovesoftware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 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 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: On 12/31/23 09:23, Roger Sayle wrote: > > Very many thanks (and a Happy New Year) to the pre-commit > patch testing folks at linaro.org. Their testing has revealed that > although my patch is clean on x86_64, it triggers some problems > on aarch64 and arm. The issue (with the previous version of my > patch) is that these platforms require a paradoxical subreg to be > generated by the middle-end, where we were previously checking > for truly_noop_truncation. > > This has been fixed (in revision 2) below. Where previously I had: > > @@ -66,7 +66,9 @@ gen_lowpart_general (machine_mode mode, rtx x) > scalar_int_mode xmode; > if (is_a (GET_MODE (x), &xmode) > && GET_MODE_SIZE (xmode) <= UNITS_PER_WORD > - && TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode) > + && (known_lt (GET_MODE_SIZE (mode), GET_MODE_SIZE (xmode)) > + ? TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode) > + : known_eq (GET_MODE_SIZE (mode), GET_MODE_SIZE (xmode))) > && !reload_completed) > return gen_lowpart_general (mode, force_reg (xmode, x)); > > the correct change is: > > scalar_int_mode xmode; > if (is_a (GET_MODE (x), &xmode) > && GET_MODE_SIZE (xmode) <= UNITS_PER_WORD > - && TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode) > + && (known_ge (GET_MODE_SIZE (mode), GET_MODE_SIZE (xmode)) > + || TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode)) > && !reload_completed) > return gen_lowpart_general (mode, force_reg (xmode, x)); > > i.e. we only call TRULY_NOOP_TRUNCATION_MODES_P when we > know we have a truncation, but the behaviour of non-truncations > is preserved (no longer depends upon unspecified behaviour) and > gen_lowpart_general is called to create the paradoxical SUBREG. > > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32} > with no new failures. Ok for mainline? > > Hopefully this revision tests cleanly on the linaro.org CI pipeline. > > 2023-12-31 Roger Sayle > > gcc/ChangeLog > * combine.cc (make_extraction): Confirm that OUTPREC is less than > INPREC before calling TRULY_NOOP_TRUNCATION_MODES_P. > * expmed.cc (store_bit_field_using_insv): Likewise. > (extract_bit_field_using_extv): Likewise. > (extract_bit_field_as_subreg): Likewise. > * optabs-query.cc (get_best_extraction_insn): Likewise. > * optabs.cc (expand_parity): Likewise. > * rtlhooks.cc (gen_lowpart_general): Likewise. > * simplify-rtx.cc (simplify_truncation): Disallow truncations > to the same precision. > (simplify_unary_operation_1) : Move optimization > of truncations to the same mode earlier. So just an FYI. This should probably wait for gcc-15. But it is worth noting that this causes tbz_2.c to fail on aarch64. Basically with this patch we use the "x" registers whereas before we used a "w" register. Meaning we're doing a 64bit comparison now rather than a 32bit comparison. THe test expects a 32bit comparison. jeff