From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id DC94F3858CD1 for ; Fri, 14 Jul 2023 14:12:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC94F3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689343963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OqdaX3Vu3eXFJjR+UX40SXJxE5AOTqBHY5cFCb4QBjc=; b=jGsdgv0Qe++Xz9VFuqr1hY5kcedKC17wJIdG91Prya1OYw70foz0+jXPIL3BY7GHSEZl+q 7itIk8FpVtxqpPhc69B4tcJ0NkoVjQ0wOQSdKvwjpKTL29CigaeMaM2fFEzNE3+10+wGdV 5Zqgli3LTbDlN0LzxLGvaGSklHRUeNE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-BbyZwBPUM0GxEcgR_IqhnQ-1; Fri, 14 Jul 2023 10:12:41 -0400 X-MC-Unique: BbyZwBPUM0GxEcgR_IqhnQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fbfc766a78so10833675e9.3 for ; Fri, 14 Jul 2023 07:12:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689343960; x=1691935960; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OqdaX3Vu3eXFJjR+UX40SXJxE5AOTqBHY5cFCb4QBjc=; b=bTTYJu6BBwWAgsAwCQ88nHOs/qPwr3Dtw6smhzaEYkr/JMLbYLQPyVpZHvYJNRrbsW F0JFmTb0ZV5duszmmSkTHwrfB8shk0Bb3woBG1yWh5ixtRTlKQncPcVbQLEEPHr7DDo+ q7RN2eiSlrI42piqXwAKhQ0aZyR14OfO8wc6UoJxfVb67lceskD3pUbjWD4FLRhS5NQf DSx9DcUgYPlG75A15TlySjj2pGii6vsTydVxlG0AMjMYnha7uEt09eZEWKmLBrPu7rZ4 rYVIEmUscraF9X/lUrgehvm4XHfKiOXid1QX6yuXoiVyf/EZGY6fYULc6ipWeGxM9dQ5 WBFQ== X-Gm-Message-State: ABy/qLYDlDIVSGWl9UuxxBunEDhFMsvdab4kbM6f/6vBlTHZGvbx3j3F g/up/SlRddZkyWIQBtZVjFlCKasqWmRnBzImDFmybUICTl9zK7NT9iKsu2uVXE1+YGllrjkf/qX cTJApWhHHPIZt0jURNQ== X-Received: by 2002:a05:600c:211a:b0:3fc:1f0:a66e with SMTP id u26-20020a05600c211a00b003fc01f0a66emr4154341wml.1.1689343960707; Fri, 14 Jul 2023 07:12:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGTxd2ZHem1SBAGoXdvNhHNBWdzuyHWJIXwwxxNYx/oVzgL91LYm9m2UYihl0JHP+FnHqNoA== X-Received: by 2002:a05:600c:211a:b0:3fc:1f0:a66e with SMTP id u26-20020a05600c211a00b003fc01f0a66emr4154319wml.1.1689343960340; Fri, 14 Jul 2023 07:12:40 -0700 (PDT) Received: from [192.168.1.100] ([139.47.41.96]) by smtp.gmail.com with ESMTPSA id q10-20020adff50a000000b003144bfbd0b3sm10994053wro.37.2023.07.14.07.12.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jul 2023 07:12:39 -0700 (PDT) Message-ID: <9a48b1fe-b50f-28a0-83a8-3d967e9aedb0@redhat.com> Date: Fri, 14 Jul 2023 16:12:38 +0200 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 V4] Optimize '(X - N * M) / N' to 'X / N - M' if valid To: Richard Biener Cc: Jiufu Guo , gcc-patches@gcc.gnu.org, amacleod@redhat.com, jeffreyalaw@gmail.com, richard.sandiford@arm.com, segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com References: <20230711090413.3587421-1-guojiufu@linux.ibm.com> <430f2117-3848-d9e5-edab-607a58a460de@redhat.com> From: Aldy Hernandez In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 7/14/23 15:37, Richard Biener wrote: > On Fri, 14 Jul 2023, Aldy Hernandez wrote: > >> I don't know what you're trying to accomplish here, as I haven't been >> following the PR, but adding all these helper functions to the ranger header >> file seems wrong, especially since there's only one use of them. I see you're >> tweaking the irange API, adding helper functions to range-op (which is only >> for code dealing with implementing range operators for tree codes), etc etc. >> >> If you need these helper functions, I suggest you put them closer to their >> uses (i.e. wherever the match.pd support machinery goes). > > Note I suggested the opposite beacuse I thought these kind of helpers > are closer to value-range support than to match.pd. Oh sorry, I missed that. > > But I take away from your answer that there's nothing close in the > value-range machinery that answers the question whether A op B may > overflow? Not currently. I vaguely recall we talked about some mechanism for doing range operations in a wider precision and comparing them with the result of doing it in the natural precision, and if the results differ, it must have overflowed. *hunts down PR* Comment 23 here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100499#c23 Would something like that work? I would prefer something more general, rather than having to re-invent every range-op entry to check for overflow. Aldy