[{"id":1772011,"web_url":"http://patchwork.ozlabs.org/comment/1772011/","msgid":"<CAFiYyc0JzxHKEA12wvh+ggWsAyne_JU7DFn=r9=0cK1WJEL1fA@mail.gmail.com>","list_archive_url":null,"date":"2017-09-20T15:54:52","subject":"Re: range_int_cst_p handling in extract_range_from_binary_expr_1","submitter":{"id":1765,"url":"http://patchwork.ozlabs.org/api/people/1765/","name":"Richard Biener","email":"richard.guenther@gmail.com"},"content":"On Wed, Sep 20, 2017 at 2:06 PM, Richard Sandiford\n<richard.sandiford@linaro.org> wrote:\n> extract_range_from_binary_expr_1 had:\n>\n>       if (range_int_cst_p (&vr0)\n>           && range_int_cst_p (&vr1)\n>           && TYPE_OVERFLOW_WRAPS (expr_type))\n>         ...\n>       ...\n>       extract_range_from_multiplicative_op_1 (vr, code, &vr0, &vr1);\n>\n> but extract_range_from_multiplicative_op_1 also requires range_int_cst_p.\n> I think we should bail out if either range isn't a constant.\n>\n> This might only be theoretical with current sources, but it's needed\n> once polynomial constants are added.\n>\n> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu.\n> OK to install?\n\nextract_range_from_multiplicative_op_1 also allows anti-ranges but indeed\nrequires INTEGER_CSTs.  Note it won't get anti-ranges because we handle\nthis case by ranges_from_anti_range.\n\nThus ok if you also remove the apparent anti-range handling from\nextract_range_from_multiplicative_op_1 (in the assert).\n\nThanks,\nRichard.\n\n> Richard\n>\n>\n> 2017-09-20  Richard Sandiford  <richard.sandiford@linaro.org>\n>             Alan Hayward  <alan.hayward@arm.com>\n>             David Sherwood  <david.sherwood@arm.com>\n>\n> gcc/\n>         * tree-vrp.c (extract_range_from_binary_expr_1): Don't call\n>         extract_range_from_multiplicative_op_1 if !range_int_cst_p.\n>\n> Index: gcc/tree-vrp.c\n> ===================================================================\n> --- gcc/tree-vrp.c      2017-08-30 12:18:46.631541422 +0100\n> +++ gcc/tree-vrp.c      2017-09-20 13:04:20.397027078 +0100\n> @@ -2462,9 +2462,14 @@ extract_range_from_binary_expr_1 (value_\n>        signop sign = TYPE_SIGN (expr_type);\n>        unsigned int prec = TYPE_PRECISION (expr_type);\n>\n> -      if (range_int_cst_p (&vr0)\n> -         && range_int_cst_p (&vr1)\n> -         && TYPE_OVERFLOW_WRAPS (expr_type))\n> +      if (!range_int_cst_p (&vr0)\n> +         || !range_int_cst_p (&vr1))\n> +       {\n> +         set_value_range_to_varying (vr);\n> +         return;\n> +       }\n> +\n> +      if (TYPE_OVERFLOW_WRAPS (expr_type))\n>         {\n>           typedef FIXED_WIDE_INT (WIDE_INT_MAX_PRECISION * 2) vrp_int;\n>           typedef generic_wide_int","headers":{"Return-Path":"<gcc-patches-return-462613-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462613-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"X3SKWq2Z\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy47s1pg8z9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 01:55:04 +1000 (AEST)","(qmail 27053 invoked by alias); 20 Sep 2017 15:54:57 -0000","(qmail 27033 invoked by uid 89); 20 Sep 2017 15:54:56 -0000","from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com)\n\t(74.125.82.48) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 20 Sep 2017 15:54:55 +0000","by mail-wm0-f48.google.com with SMTP id 13so8524751wmq.2 for\n\t<gcc-patches@gcc.gnu.org>; Wed, 20 Sep 2017 08:54:55 -0700 (PDT)","by 10.80.143.34 with HTTP; Wed, 20 Sep 2017 08:54:52 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; q=dns; s=default; b=lEWYBrkNX1ORSD0gYa\n\toe36zHRnJ3xRor4iPckptgSL52I4720uxtvxzmnIoeghjQFK/hbfqsUVB9rod26/\n\t0Q8qC6CnCha761npPb/6kmgObrkynK/fOtbKnum98V9agPeUmMs8eckJTv4piOKX\n\t8g/kfmaXdjtNVPPT/eQ3XiENY=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; s=default; bh=2ijG9DJYCObVfDgHqEQuO8wk\n\tpNM=; b=X3SKWq2ZcB7grV2NVYuxYLX/41yYcwXZK7yAYqZBMaqzDldFfEz/gMbx\n\tbaxCWI2TaLU9NOjH8dxyEYIg8vuwnykEcW7RCKHCDNj1yGJB+N40XQ6QunxjrarL\n\tZfKepI/p/szjv+IC5fKpYbBSbkRuZTjPo/qY6ybQL439NAq56dM=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-10.5 required=5.0 tests=AWL, BAYES_00,\n\tFREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=apparent","X-HELO":"mail-wm0-f48.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to;\n\tbh=Irsrujb/XnUPRlWVzrgda/pxuY7UHgY5LtQXhqiYhgY=;\n\tb=EwvbdmoMCh4ymEv+TrKrVCc8UuBtEFjiH9FSZxyYpRGvmhlps+XWNfn+TTKZJD6wjk\n\tXrAE/nxmnX4GyNIS3IgsQeAwYB6wV6RbPIgeOsDqRHrckE6Y2w0U8rtxwQhJzVgsnIl5\n\tfSCrP/bI5qohqFxOOAOjIAcGLQQOlwr4XTPwmglwgLbaiq3ufTCv/Ty2zt8didllPeV1\n\tjp37G/TZ3IAkLc1/jHjW5f6R3KjiIBFzM3zvulMcdXDkkQXvH4XIJpCxBwgRK+CeROEa\n\tNx1he1owCNbpk8/JN8P8RJbqfIIj8cnRRjBWyJ0QsinAHqvtui3Rm1xf7hXl/tY+y4Jv\n\tPmfQ==","X-Gm-Message-State":"AHPjjUgxKTTOYRYE0SQlvNNaAMZTY5ymbEk/b3oMql0T+3XV5niiTp/K\tgmeuS0cHRZZKUfneo1EaBuqQvwaEIlu8xvb4fl5qv65A","X-Google-Smtp-Source":"AOwi7QAYxFyUWOpaXFC2ErWqDNP9AGqE09zjp3bbHM8BAiVO8vEi8Ab3ATCZ+JjjrApvpZrE1e71Xx3ed1nPooU049c=","X-Received":"by 10.80.175.228 with SMTP id h91mr5072885edd.292.1505922893292;\n\tWed, 20 Sep 2017 08:54:53 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<87vakd1sn3.fsf@linaro.org>","References":"<87vakd1sn3.fsf@linaro.org>","From":"Richard Biener <richard.guenther@gmail.com>","Date":"Wed, 20 Sep 2017 17:54:52 +0200","Message-ID":"<CAFiYyc0JzxHKEA12wvh+ggWsAyne_JU7DFn=r9=0cK1WJEL1fA@mail.gmail.com>","Subject":"Re: range_int_cst_p handling in extract_range_from_binary_expr_1","To":"GCC Patches <gcc-patches@gcc.gnu.org>,\n\tRichard Sandiford <richard.sandiford@linaro.org>","Content-Type":"text/plain; charset=\"UTF-8\"","X-IsSubscribed":"yes"}},{"id":1773775,"web_url":"http://patchwork.ozlabs.org/comment/1773775/","msgid":"<87tvzupt0w.fsf@linaro.org>","list_archive_url":null,"date":"2017-09-22T17:01:03","subject":"Re: range_int_cst_p handling in extract_range_from_binary_expr_1","submitter":{"id":5450,"url":"http://patchwork.ozlabs.org/api/people/5450/","name":"Richard Sandiford","email":"richard.sandiford@linaro.org"},"content":"Richard Biener <richard.guenther@gmail.com> writes:\n> On Wed, Sep 20, 2017 at 2:06 PM, Richard Sandiford\n> <richard.sandiford@linaro.org> wrote:\n>> extract_range_from_binary_expr_1 had:\n>>\n>>       if (range_int_cst_p (&vr0)\n>>           && range_int_cst_p (&vr1)\n>>           && TYPE_OVERFLOW_WRAPS (expr_type))\n>>         ...\n>>       ...\n>>       extract_range_from_multiplicative_op_1 (vr, code, &vr0, &vr1);\n>>\n>> but extract_range_from_multiplicative_op_1 also requires range_int_cst_p.\n>> I think we should bail out if either range isn't a constant.\n>>\n>> This might only be theoretical with current sources, but it's needed\n>> once polynomial constants are added.\n>>\n>> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu.\n>> OK to install?\n>\n> extract_range_from_multiplicative_op_1 also allows anti-ranges but indeed\n> requires INTEGER_CSTs.  Note it won't get anti-ranges because we handle\n> this case by ranges_from_anti_range.\n>\n> Thus ok if you also remove the apparent anti-range handling from\n> extract_range_from_multiplicative_op_1 (in the assert).\n\nThanks, here's what I committed after testing as before.\n\nRichard\n\n\n2017-09-22  Richard Sandiford  <richard.sandiford@linaro.org>\n\t    Alan Hayward  <alan.hayward@arm.com>\n\t    David Sherwood  <david.sherwood@arm.com>\n\ngcc/\n\t* tree-vrp.c (extract_range_from_multiplicative_op_1): Assert\n\tfor VR_RANGE only; don't allow VR_ANTI_RANGE.\n\t(extract_range_from_binary_expr_1): Don't call\n\textract_range_from_multiplicative_op_1 if !range_int_cst_p.\n\nIndex: gcc/tree-vrp.c\n===================================================================\n--- gcc/tree-vrp.c\t2017-09-21 22:35:16.639777740 +0100\n+++ gcc/tree-vrp.c\t2017-09-22 17:46:45.207205032 +0100\n@@ -1851,8 +1851,7 @@ extract_range_from_multiplicative_op_1 (\n \t      || code == ROUND_DIV_EXPR\n \t      || code == RSHIFT_EXPR\n \t      || code == LSHIFT_EXPR);\n-  gcc_assert ((vr0->type == VR_RANGE\n-\t       || (code == MULT_EXPR && vr0->type == VR_ANTI_RANGE))\n+  gcc_assert (vr0->type == VR_RANGE\n \t      && vr0->type == vr1->type);\n \n   rtype = vr0->type;\n@@ -2462,9 +2461,14 @@ extract_range_from_binary_expr_1 (value_\n       signop sign = TYPE_SIGN (expr_type);\n       unsigned int prec = TYPE_PRECISION (expr_type);\n \n-      if (range_int_cst_p (&vr0)\n-\t  && range_int_cst_p (&vr1)\n-\t  && TYPE_OVERFLOW_WRAPS (expr_type))\n+      if (!range_int_cst_p (&vr0)\n+\t  || !range_int_cst_p (&vr1))\n+\t{\n+\t  set_value_range_to_varying (vr);\n+\t  return;\n+\t}\n+\n+      if (TYPE_OVERFLOW_WRAPS (expr_type))\n \t{\n \t  typedef FIXED_WIDE_INT (WIDE_INT_MAX_PRECISION * 2) vrp_int;\n \t  typedef generic_wide_int","headers":{"Return-Path":"<gcc-patches-return-462796-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462796-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"GIqpa0fD\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xzKWL3qghz9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 23 Sep 2017 03:01:18 +1000 (AEST)","(qmail 67628 invoked by alias); 22 Sep 2017 17:01:11 -0000","(qmail 67619 invoked by uid 89); 22 Sep 2017 17:01:10 -0000","from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com)\n\t(209.85.128.171) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 22 Sep 2017 17:01:09 +0000","by mail-wr0-f171.google.com with SMTP id u96so1382249wrb.6 for\n\t<gcc-patches@gcc.gnu.org>; Fri, 22 Sep 2017 10:01:09 -0700 (PDT)","from localhost (94.197.121.89.threembb.co.uk. [94.197.121.89]) by\n\tsmtp.gmail.com with ESMTPSA id\n\tx15sm141132wma.32.2017.09.22.10.01.05 (version=TLS1_2\n\tcipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tFri, 22 Sep 2017 10:01:06 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:from\n\t:to:cc:subject:references:date:in-reply-to:message-id\n\t:mime-version:content-type; q=dns; s=default; b=v7i7ylqxipAanz/9\n\tvxE3/q35rQIfAfVq/i/zD2FhyN2YkXPiAkuOV0hYjd36M4LR98jptoWWhe8LBXwx\n\tSdmhyL1iiuaVCclhKkxD9aZGSnCbHch36DXYHkyoGUPXQzITuncjD0ToX9lYyJLa\n\tt3jTfreZ57LZi9Zc7XQgC0SXJt4=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:from\n\t:to:cc:subject:references:date:in-reply-to:message-id\n\t:mime-version:content-type; s=default; bh=sDBvoLCCIgYKm/RmqAQTtL\n\tYi1iU=; b=GIqpa0fDnWOarIhqapEwEw6eIxqDsZ55IC75NiB2RUieaaGQwgeQgi\n\ts54jk6ceRltP1kBh3D8aQhl7EmAg6LkuzruXeShlN5BeTek0YJ9PWXSZnAa57ASB\n\t2KW6M44AvTD4AHUswTxK7b5YfjIhszsD7LZEQAWMYL9e1M9rupVDQ=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-12.0 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"mail-wr0-f171.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:from:to:mail-followup-to:cc:subject:references\n\t:date:in-reply-to:message-id:user-agent:mime-version;\n\tbh=51Q4VBjkI+Q5mTccCdHnrsgUy6bO9JwCV/9PKV+LgEo=;\n\tb=F8YbXiNqIBXAcfk/u+lmYSq8LxlO5gC4TegvWsvsfvrhyh76/TBcvHeqIsXEnAygjJ\n\tEfQBZzCBk0IyggK76pWIgPs1qI5xCRTj/qH1IQJS4Kj2nEX/6CngAx7IW/h+aF0DlgXg\n\t0qjIVmqFDkr7FV1zD0sm6+x9kP45J1FEGE+L9PovFNp8muVi3OIj86+yyNoxrU0QHrs/\n\thkMEw8XenyYlIXNKC+qtBpw9+ikL8vxskRDxKnRb2PXFOrPRRq65vZk2RDrSWOnVl61t\n\tdhV6NvLC8aE1jYIDK6IWLf1Uo/RY2KNzF7HPAIbBVomoD34f67PFXwEzWKGS3j5agitR\n\tU5lA==","X-Gm-Message-State":"AHPjjUi+y73TLK3NxKy3b//J0hjua/7zL9u4fK6t2fsvRjkH6AEOZVVI\tysmutr1cq0b9oI0xJcW+KQc+tVQtaW4=","X-Google-Smtp-Source":"AOwi7QCzCquOWR4oUy3bDEttJxsys2V3lBhmoC3eGBkDmPrxTr0yeXtkoaYMlO23yqsV+jGYVIOO8A==","X-Received":"by 10.223.139.200 with SMTP id w8mr6047444wra.172.1506099667123;\n\tFri, 22 Sep 2017 10:01:07 -0700 (PDT)","From":"Richard Sandiford <richard.sandiford@linaro.org>","To":"Richard Biener <richard.guenther@gmail.com>","Mail-Followup-To":"Richard Biener <richard.guenther@gmail.com>,\n\tGCC Patches <gcc-patches@gcc.gnu.org>,\n\trichard.sandiford@linaro.org","Cc":"GCC Patches <gcc-patches@gcc.gnu.org>","Subject":"Re: range_int_cst_p handling in extract_range_from_binary_expr_1","References":"<87vakd1sn3.fsf@linaro.org>\t<CAFiYyc0JzxHKEA12wvh+ggWsAyne_JU7DFn=r9=0cK1WJEL1fA@mail.gmail.com>","Date":"Fri, 22 Sep 2017 18:01:03 +0100","In-Reply-To":"<CAFiYyc0JzxHKEA12wvh+ggWsAyne_JU7DFn=r9=0cK1WJEL1fA@mail.gmail.com>\t(Richard\n\tBiener's message of \"Wed, 20 Sep 2017 17:54:52 +0200\")","Message-ID":"<87tvzupt0w.fsf@linaro.org>","User-Agent":"Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)","MIME-Version":"1.0","Content-Type":"text/plain"}}]