From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id CB9293858D37 for ; Mon, 26 Sep 2022 23:27:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB9293858D37 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-x42e.google.com with SMTP id y136so8185808pfb.3 for ; Mon, 26 Sep 2022 16:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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; bh=fP6oLGGPzkjwSYcvL6yKShRoYM1BUUCkm/X1knWNLNQ=; b=NyHn3J0KhsElav2hZ3UwbCWBHNLAWgTlOEQ7s5fAQFDTd2UTvNqxw7UHCOQPjeKQdJ ji3CqKqqgVrs7akBvs7nzrzJxQk8salWWZ9F4+/Lt7ytIiX578UnIwHQZEhSTqq8cJwx v4RLNHbNEuhAxXZy0BPf528M7zlNJLqKRI1Zf+apW6vVhTfeCTG69TbNciQxZjyLym1r SiA/qOAoh33vMt0WunRlhwJnj8k+xPbJIJ7XmBAOU5r3pwzO5B26vOEsJVY1HK9LTUcc uLEhGgn2Dhx0wVW1byT5NyhFNA69pyeRMMnW4+KT11BIS1e0jSu4JoB4H1+6Aq15o7Cc z83Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=fP6oLGGPzkjwSYcvL6yKShRoYM1BUUCkm/X1knWNLNQ=; b=BJmB1k+XMeWRfos3wUdjnvQEUCQicp6BFoptNbFYLmrrmwwngAcAC5P9oUp0/LwN7t FlmvUxBmBD5fVMpFyDwrFfWg7s5Bfgduoq+i6Pe+U/b0EspT64RPquzVJJ6kGhM5VTnJ WNe0AGARt5k83qcW0bBhW/RNrFmjTzcHPSaJupJ7081tNRrEiWz91TXyXLiOOIL4Ppus TFjREmwQKL6WtBEoqZOj6VF2kwBgKy4sfWTfzXE5/gyUxalco17Uc8lly5bO6CTPExEn 9gKo0SuTKVsNbZmnzSCXH+s2EZA3XxjFNnFKRYd4brhQ3a45VL6TSQzb8zRggmMA4Zkx +3qw== X-Gm-Message-State: ACrzQf3htD2RvW3RJOJVHDbzo2lgWir4BAmtlpWbDcmVXfNmG7OGBiuO ysTKGwFmqyZQYZ5U6apAvAkw6zDxA9SjKw== X-Google-Smtp-Source: AMsMyM5w6VXqx7WVKRnDkH8h6RY+pnaShUQeWyZIEnsUkbFpswU9ULYE0ul4aPNkkqaF43qEly62AQ== X-Received: by 2002:a05:6a00:9a9:b0:541:787f:f2c with SMTP id u41-20020a056a0009a900b00541787f0f2cmr26363899pfg.12.1664234859478; Mon, 26 Sep 2022 16:27:39 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id i1-20020a1709026ac100b00178a8f4d4f2sm1119plt.74.2022.09.26.16.27.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 16:27:38 -0700 (PDT) Message-ID: <03c09537-4a4a-f77c-98b3-86808b1dd962@gmail.com> Date: Mon, 26 Sep 2022 17:27:37 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [COMMITTED] Optimize [0 = x & MASK] in range-ops. Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <20220926172441.3219466-1-aldyh@redhat.com> From: Jeff Law In-Reply-To: <20220926172441.3219466-1-aldyh@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,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 List-Id: On 9/26/22 11:24, Aldy Hernandez via Gcc-patches wrote: > For [0 = x & MASK], we can determine that x is ~MASK. This is > something we're picking up in DOM thanks to maybe_set_nonzero_bits, > but is something we should handle natively. > > This is a good example of how much easier to maintain the range-ops > entries are versus the ad-hoc pattern matching stuff we had to do > before. For the curious, compare the changes to range-op here, > versus maybe_set_nonzero_bits. > > I'm leaving the call to maybe_set_nonzero_bits until I can properly > audit it to make sure we're catching it all in range-ops. It won't > hurt, since both set_range_info() and set_nonzero_bits() are > intersect operations, so we'll never lose information if we do both. > > Tested on x86-64 Linux. > > PR tree-optimization/107009 > > gcc/ChangeLog: > > * range-op.cc (operator_bitwise_and::op1_range): Optimize 0 = x & MASK. > (range_op_bitwise_and_tests): New test. Umm, 0 = x & MASK; Just means that X has no bits set in MASK.   So you can use it to set nonzero-bits to ~MASK like your patch does and you can use that to refine a result.  So it's really the comment that is misleading/wrong. jeff