From patchwork Tue Sep 11 10:18:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 968487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485427-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xBtUV7tE"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 428gqL48jjz9s4s for ; Tue, 11 Sep 2018 20:18:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=vQnp9HnNIMC7Gtj3uLCuHFnvwvz6nVo+uTVnn674Hp+MD9FRvu 5qfCiIzxdZJbH+kG17fpT3XBTw0kuEwRbEkx4WBp6dphRfFiXAxM3DKe2nJ8QXgD Ld/GwOUgcqvfhFmkQnSPyLkAlpGpTiz50vNQGMcP1kFKercNwce/L+zgE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=WmtFWj8ffn5CqmdiWudOwbR1gfs=; b=xBtUV7tEYLFTfEu0gjRy ajSuwl9s6X8Z3a7Bl3AW1fzXPziixFa5v5HmPf59L+VHvAj7aefG/QLVyWMjYRuP ww5QyguyNjIwPY/p0d/vXeMu8quGYnroCXcA/4fiUW54bARZ45aD2zz71dh9uMMh EsVytvNLeOkm9dloMwzAKgI= Received: (qmail 38275 invoked by alias); 11 Sep 2018 10:18:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 38265 invoked by uid 89); 11 Sep 2018 10:18:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=divisions X-HELO: mail-wr1-f42.google.com Received: from mail-wr1-f42.google.com (HELO mail-wr1-f42.google.com) (209.85.221.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Sep 2018 10:18:28 +0000 Received: by mail-wr1-f42.google.com with SMTP id v90-v6so25383625wrc.0 for ; Tue, 11 Sep 2018 03:18:27 -0700 (PDT) Received: from abulafia.quesejoda.com ([62.252.144.58]) by smtp.gmail.com with ESMTPSA id y17-v6sm25934831wrm.61.2018.09.11.03.18.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 03:18:25 -0700 (PDT) To: gcc-patches From: Aldy Hernandez Subject: [committed] VRP: Treat all divisions by zero as VR_UNDEFINED. Message-ID: <2d4984ff-db02-03c0-77b9-73d0695b59f1@redhat.com> Date: Tue, 11 Sep 2018 06:18:24 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Doing this was approved by Richi at some point when I rewrote the division code. I finally got around to testing it. Committed. gcc/ * tree-vrp (extract_range_from_binary_expr_1): Treat all divisions by zero as VR_UNDEFINED. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 8f16713300c..a82cf3e36c1 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1601,12 +1601,7 @@ extract_range_from_binary_expr_1 (value_range *vr, /* Special case explicit division by zero as undefined. */ if (range_is_null (&vr1)) { - /* However, we must not eliminate a division by zero if - flag_non_call_exceptions. */ - if (cfun->can_throw_non_call_exceptions) - set_value_range_to_varying (vr); - else - set_value_range_to_undefined (vr); + set_value_range_to_undefined (vr); return; }