From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id A306638582BE for ; Mon, 31 Jul 2023 13:59:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A306638582BE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-686e0213c0bso3037606b3a.1 for ; Mon, 31 Jul 2023 06:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690811962; x=1691416762; 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=gR2q9e+QHdeQVukAENqJ/EIkhdx4IicI5q7qoFlvQGw=; b=dX0eB6Ac2Fze7gYF+1p3QN/IQmqaQFiEsC3tWEpqPuRIOmS+hZciqlbv4tDRp8pKoS g3u9ofn2o2Z8Z2nW37KqvimoYiAk5YHjWauLev+XQOT4mYbspmtTUT7ePXqE1P4Bc8RM h699yWwJ6tv72M6wTZNIVtGkRcBaYC3gr3fU0eCzZicKdkHtGgxPYtqJbsSJh4TovJIg yfftCsw9hwuigHsVjGRcP6e/6L//huF+rWW4D2E17Sefxz4wIkET4j4th+sGqfNtFogc K7qbj4uNwaQaWZBVWjmE57WC2xAyMHzKADh9sxuw82SpZEImKXPes/ZXLIN72+nNwRXN hSXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690811962; x=1691416762; 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=gR2q9e+QHdeQVukAENqJ/EIkhdx4IicI5q7qoFlvQGw=; b=Z2LEck/TWyuBiMxba6JWPaiq9+uqrnU02FqwAI7okT1htgYcIuqClr1cqdlunbAUfo GrK8iz0u4gumUov3f/Hk+MrraPnK0FFHZMSvcCRIyhbr6vLkKb2Px4sFTSgJyByRUwUs e73gi2MU4kvnnuFH+oYXZ06MdWU3Ln7mh73Va+zI3iAd7WeW+DZBq7KohKXO7tLT36Ev qKys1S1JH6sL3CTj0c3J3qznVVnTi3xb5vjeZiBlie4kgK+ErxOdCLECEdOuuiaGHScd Z3poe02nekp5UgCtCElu7B55Xu1QMb/GRW0UhL13Ju+EVqxzWyjvd9Ek906HaDOtV2jt 75Jw== X-Gm-Message-State: ABy/qLb93q5K47alnF+ZVpgqPgDmiiy32oKyObNBzeQs7kjGlO3D4eAM cD33ZbBxQ+tNKy4TYjNlz7U= X-Google-Smtp-Source: APBJJlHsfuvApPWBW3gEU7LUVePb0B37AVd2xgNXaTgFu2qnhGDOaqEfNlZWdRehxaXxDxVjwPbb9A== X-Received: by 2002:a05:6a20:12ca:b0:126:f64b:668e with SMTP id v10-20020a056a2012ca00b00126f64b668emr10165718pzg.5.1690811961599; Mon, 31 Jul 2023 06:59:21 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id fk25-20020a056a003a9900b00682a8e600f0sm7686115pfb.35.2023.07.31.06.59.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Jul 2023 06:59:21 -0700 (PDT) Message-ID: Date: Mon, 31 Jul 2023 07:59:19 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2] combine: Narrow comparison of memory and constant Content-Language: en-US To: Stefan Schulze Frielinghaus , gcc-patches@gcc.gnu.org References: <20230619142356.345159-1-stefansf@linux.ibm.com> From: Jeff Law In-Reply-To: <20230619142356.345159-1-stefansf@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,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 6/19/23 08:23, Stefan Schulze Frielinghaus via Gcc-patches wrote: > Comparisons between memory and constants might be done in a smaller mode > resulting in smaller constants which might finally end up as immediates > instead of in the literal pool. > > For example, on s390x a non-symmetric comparison like > x <= 0x3fffffffffffffff > results in the constant being spilled to the literal pool and an 8 byte > memory comparison is emitted. Ideally, an equivalent comparison > x0 <= 0x3f > where x0 is the most significant byte of x, is emitted where the > constant is smaller and more likely to materialize as an immediate. > > Similarly, comparisons of the form > x >= 0x4000000000000000 > can be shortened into x0 >= 0x40. > > Bootstrapped and regtested on s390x, x64, aarch64, and powerpc64le. > Note, the new tests show that for the mentioned little-endian targets > the optimization does not materialize since either the costs of the new > instructions are higher or they do not match. Still ok for mainline? > > gcc/ChangeLog: > > * combine.cc (simplify_compare_const): Narrow comparison of > memory and constant. > (try_combine): Adapt new function signature. > (simplify_comparison): Adapt new function signature. > > gcc/testsuite/ChangeLog: > > * gcc.dg/cmp-mem-const-1.c: New test. > * gcc.dg/cmp-mem-const-2.c: New test. > * gcc.dg/cmp-mem-const-3.c: New test. > * gcc.dg/cmp-mem-const-4.c: New test. > * gcc.dg/cmp-mem-const-5.c: New test. > * gcc.dg/cmp-mem-const-6.c: New test. > * gcc.target/s390/cmp-mem-const-1.c: New test. Sorry. I'd looked at this a while back, wanted to take another looksie and totally forgot about it. OK for the trunk. Thanks for your patience. jeff