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 44FC33858D35 for ; Tue, 16 Apr 2024 14:06:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 44FC33858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 44FC33858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276404; cv=none; b=SXajON1NOk1tvdOadxVY5HDrkSTd3d2RSqWgRW0gcw3jSimF/RCjGaDa13uHdeAHNQLKxh7juUsQl7+TIzGHi/ijzdhIyid8EO2pcUDSs7Fb0s92Lv0aBTllSfXw6vbSBECER+2RgI954xFcNPsDmWhY24FBIqDv5tIGY4lWl4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276404; c=relaxed/simple; bh=rhVPlEqFIk6sOj6NrdHa/2JPb/DUkMp8IYDnDJQ+k10=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=aRhVYLdDVX9Dq/1/ZV5AzBKzC8YoJ0pDF8+g5i9yJ3N5gSdtoPmcbzb+d1U5EGEf9NKXNGrD+87GHv5YqpxxUQMd3lX8NyUTJUfO/9tYQphIuhjQp4QsQeuTM235hK45vHNoENRv78oyUM2LyFcDuYKvFkIQBZm3NeSHFQDicHY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713276392; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=zeEzgO1Kl6607q3YrCfR71SH1BCs0yayNj/WKbwAP58=; b=C88GaWPJ7OqFdMxg7dXlkfIvo6V5MB0Ca9/7FoKlBbEc/QU4qnElHbKtXksCo9iNWuj/4V qp7CtsrM/BRXmI87iCSJtEykSUlSVL//uWGhbObCveyqolSb4L8m5sRxLMfg2G4v0qI+wK VLH0CPZzMuWx63ynYTGL2j/FVGDb85A= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-RyjvtDV0OI2ay7TVx1XmxA-1; Tue, 16 Apr 2024 10:06:29 -0400 X-MC-Unique: RyjvtDV0OI2ay7TVx1XmxA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3066D28B7403; Tue, 16 Apr 2024 14:06:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E86DB40C6CB2; Tue, 16 Apr 2024 14:06:28 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 43GE67D4460467 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 16 Apr 2024 16:06:07 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 43GE664m460466; Tue, 16 Apr 2024 16:06:06 +0200 Date: Tue, 16 Apr 2024 16:06:06 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] middle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR Message-ID: Reply-To: Jakub Jelinek References: <36467.124041610010004075@us-mta-690.us.mimecast.lan> MIME-Version: 1.0 In-Reply-To: <36467.124041610010004075@us-mta-690.us.mimecast.lan> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 Tue, Apr 16, 2024 at 04:00:59PM +0200, Richard Biener wrote: > Currently we expand POINTER_DIFF_EXPR using subv_optab when -ftrapv > (but -fsanitize=undefined does nothing). That's not consistent > with the behavior of POINTER_PLUS_EXPR which never uses addv_optab > with -ftrapv. Both are because of the way we select whether to use > the trapping or the non-trapping optab - we look at the result type > of the expression and check > > trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type); > > the bugreport correctly complains that -ftrapv affects pointer > subtraction (there's no -ftrapv-pointer). Now that we have > POINTER_DIFF_EXPR we can honor that appropriately. > > The patch moves both POINTER_DIFF_EXPR and POINTER_PLUS_EXPR > handling so they will never consider trapping (or saturating) > optabs. > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > OK for stage1? > > Thanks, > Richard. > > PR middle-end/13421 > * optabs-tree.cc (optab_for_tree_code): Do not consider > {add,sub}v or {us,ss}{add,sub} optabs for POINTER_DIFF_EXPR > or POINTER_PLUS_EXPR. LGTM. Jakub