Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/806757/?format=api
{ "id": 806757, "url": "http://patchwork.ozlabs.org/api/patches/806757/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/32664487-31CB-4383-B475-8AF865E05C72@linux.vnet.ibm.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<32664487-31CB-4383-B475-8AF865E05C72@linux.vnet.ibm.com>", "list_archive_url": null, "date": "2017-08-28T20:16:44", "name": "[v3] Fix PR81503 (SLSR invalid fold)", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "58229d2908dd6969d72a376b9d2cb72c72fa2c53", "submitter": { "id": 6459, "url": "http://patchwork.ozlabs.org/api/people/6459/?format=api", "name": "Bill Schmidt", "email": "wschmidt@linux.vnet.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/32664487-31CB-4383-B475-8AF865E05C72@linux.vnet.ibm.com/mbox/", "series": [ { "id": 251, "url": "http://patchwork.ozlabs.org/api/series/251/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=251", "date": "2017-08-28T20:16:44", "name": "[v3] Fix PR81503 (SLSR invalid fold)", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/251/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/806757/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/806757/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-return-461048-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-461048-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=\"eQNE4297\"; 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 3xh32x0s1Cz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 29 Aug 2017 06:17:11 +1000 (AEST)", "(qmail 70894 invoked by alias); 28 Aug 2017 20:17:02 -0000", "(qmail 69654 invoked by uid 89); 28 Aug 2017 20:17:01 -0000", "from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com)\n\t(148.163.158.5) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 28 Aug 2017 20:16:51 +0000", "from pps.filterd (m0098420.ppops.net [127.0.0.1])\tby\n\tmx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv7SKDpC8019623\tfor <gcc-patches@gcc.gnu.org>;\n\tMon, 28 Aug 2017 16:16:50 -0400", "from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153])\tby\n\tmx0b-001b2d01.pphosted.com with ESMTP id\n\t2cmr22phg4-1\t(version=TLSv1.2 cipher=AES256-SHA bits=256\n\tverify=NOT)\tfor <gcc-patches@gcc.gnu.org>;\n\tMon, 28 Aug 2017 16:16:49 -0400", "from localhost\tby e35.co.us.ibm.com with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted\tfor\n\t<gcc-patches@gcc.gnu.org> from <wschmidt@linux.vnet.ibm.com>;\n\tMon, 28 Aug 2017 14:16:48 -0600", "from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20)\tby\n\te35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted;\n\tMon, 28 Aug 2017 14:16:46 -0600", "from b03ledav001.gho.boulder.ibm.com\n\t(b03ledav001.gho.boulder.ibm.com [9.17.130.232])\tby\n\tb03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0)\n\twith ESMTP id v7SKGjgp27852978; Mon, 28 Aug 2017 13:16:45 -0700", "from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1])\tby\n\tIMSVA (Postfix) with ESMTP id 8B6426E045;\n\tMon, 28 Aug 2017 14:16:45 -0600 (MDT)", "from bigmac.rchland.ibm.com (unknown [9.10.86.161])\tby\n\tb03ledav001.gho.boulder.ibm.com (Postfix) with ESMTPS id\n\t4A9136E03F; Mon, 28 Aug 2017 14:16:45 -0600 (MDT)" ], "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:content-type:mime-version:subject:from:in-reply-to:date:cc\n\t:content-transfer-encoding:references:to:message-id; q=dns; s=\n\tdefault; b=F92dfwGdpgGX+MdJ+gzrjDmooEMbHC3sWS3WuA60KtRT6RzSsAsIG\n\tjEJVNeKdjB7a32gBoCb86/qT9B4ezow2foLh9U9BqxBM84NQfSsYJbUhdpgubKZU\n\tTlMKGV84qb6+jkzLSX+09SpWHAdgy3cOLQfsnFN3gQEjNjy31+1k2Q=", "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:content-type:mime-version:subject:from:in-reply-to:date:cc\n\t:content-transfer-encoding:references:to:message-id; s=default;\n\tbh=0T3/ryP9cztkUwnsWszMX7S9r00=; b=eQNE4297L1d/YCDpDKUM2Nb+U8y/\n\tabuMLG9dwKosKC4Pq0XfPVvPabr35h9cqkW+M8D6aEII7CCc33fJmyEik2Xh5em1\n\tpoL8bv1wxMIi+SANDshD6+5mGJ+b8YbXlMhtwphhQCVZ+lfz/kMfhRoHDIA2ceJs\n\tFIJLM5j9yZ8o7SI=", "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.4 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tKAM_LAZY_DOMAIN_SECURITY,\n\tRCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=", "X-HELO": "mx0a-001b2d01.pphosted.com", "Content-Type": "text/plain; charset=us-ascii", "Mime-Version": "1.0 (Mac OS X Mail 10.3 \\(3273\\))", "Subject": "[PATCH v3] Fix PR81503 (SLSR invalid fold)", "From": "Bill Schmidt <wschmidt@linux.vnet.ibm.com>", "In-Reply-To": "<CAFiYyc0J+d9Sr-OwSh+a+axnaqkmeNgvpE9HKgNPypgjxMO-oQ@mail.gmail.com>", "Date": "Mon, 28 Aug 2017 15:16:44 -0500", "Cc": "Jakub Jelinek <jakub@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>", "Content-Transfer-Encoding": "quoted-printable", "References": "<7bd4dcbb-cce0-82bb-b938-ffd85dd0e72a@linux.vnet.ibm.com>\n\t<20170803162022.GB2123@tucnak>\n\t<AC8B3792-9F2D-4C03-9331-2DB32D7A09A7@linux.vnet.ibm.com>\n\t<20170803163950.GD2123@tucnak>\n\t<D0D720AD-09CA-4AF1-8C8D-E5C0EBD2483F@linux.vnet.ibm.com>\n\t<c3f05b38-871a-fbb2-e744-014cee2a1070@linux.vnet.ibm.com>\n\t<CAFiYyc0J+d9Sr-OwSh+a+axnaqkmeNgvpE9HKgNPypgjxMO-oQ@mail.gmail.com>", "To": "Richard Biener <richard.guenther@gmail.com>", "X-TM-AS-GCONF": "00", "x-cbid": "17082820-0012-0000-0000-000014ECB031", "X-IBM-SpamModules-Scores": "", "X-IBM-SpamModules-Versions": "BY=3.00007628; HX=3.00000241; KW=3.00000007;\n\tPH=3.00000004; SC=3.00000226; SDB=6.00908948; UDB=6.00455801;\n\tIPR=6.00689199; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005;\n\tZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000;\n\tZU=6.00000002; MB=3.00016906; XFM=3.00000015;\n\tUTC=2017-08-28 20:16:47", "X-IBM-AV-DETECTION": "SAVI=unused REMOTE=unused XFE=unused", "x-cbparentid": "17082820-0013-0000-0000-00004F437442", "Message-Id": "<32664487-31CB-4383-B475-8AF865E05C72@linux.vnet.ibm.com>", "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-28_11:, , signatures=0", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0 malwarescore=0 phishscore=0\n\tadultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx\n\tscancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1708280319", "X-IsSubscribed": "yes" }, "content": "> On Aug 28, 2017, at 7:37 AM, Richard Biener <richard.guenther@gmail.com> wrote:\n> \n> Not sure, but would it be fixed in a similar way when writing\n<snip>\n> ?\n\nThanks, Richard, that works very well. I decided this was a good opportunity to also\nsimplify the control flow a little with early returns. Here's the result. Bootstrapped and\ntested on powerpc64le-linux-gnu with no regressions. Is this ok for trunk, and\neventually for backport to gcc 5, 6, and 7? (I can omit the control flow cleanups for\nthe older releases if desired.)\n\nThanks,\nBill\n\n[gcc]\n\n2017-08-03 Bill Schmidt <wschmidt@linux.vnet.ibm.com>\n\t Jakub Jelinek <jakub@redhat.com>\n\t Richard Biener <rguenther@suse.de>\n\n\tPR tree-optimization/81503\n\t* gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure\n\tfolded constant fits in the target type; reorder tests for clarity.\n\n[gcc/testsuite]\n\n2017-08-03 Bill Schmidt <wschmidt@linux.vnet.ibm.com>\n\t Jakub Jelinek <jakub@redhat.com>\n\t Richard Biener <rguenther@suse.de>\n\n\tPR tree-optimization/81503\n\t* gcc.c-torture/execute/pr81503.c: New file.", "diff": "Index: gcc/gimple-ssa-strength-reduction.c\n===================================================================\n--- gcc/gimple-ssa-strength-reduction.c\t(revision 251369)\n+++ gcc/gimple-ssa-strength-reduction.c\t(working copy)\n@@ -2089,104 +2089,104 @@ replace_mult_candidate (slsr_cand_t c, tree basis_\n tree target_type = TREE_TYPE (gimple_assign_lhs (c->cand_stmt));\n enum tree_code cand_code = gimple_assign_rhs_code (c->cand_stmt);\n \n- /* It is highly unlikely, but possible, that the resulting\n- bump doesn't fit in a HWI. Abandon the replacement\n- in this case. This does not affect siblings or dependents\n- of C. Restriction to signed HWI is conservative for unsigned\n- types but allows for safe negation without twisted logic. */\n- if (wi::fits_shwi_p (bump)\n- && bump.to_shwi () != HOST_WIDE_INT_MIN\n- /* It is not useful to replace casts, copies, negates, or adds of\n-\t an SSA name and a constant. */\n- && cand_code != SSA_NAME\n- && !CONVERT_EXPR_CODE_P (cand_code)\n- && cand_code != PLUS_EXPR\n- && cand_code != POINTER_PLUS_EXPR\n- && cand_code != MINUS_EXPR\n- && cand_code != NEGATE_EXPR)\n+ /* It is not useful to replace casts, copies, negates, or adds of\n+ an SSA name and a constant. */\n+ if (cand_code == SSA_NAME\n+ || CONVERT_EXPR_CODE_P (cand_code)\n+ || cand_code == PLUS_EXPR\n+ || cand_code == POINTER_PLUS_EXPR\n+ || cand_code == MINUS_EXPR\n+ || cand_code == NEGATE_EXPR)\n+ return;\n+\n+ enum tree_code code = PLUS_EXPR;\n+ tree bump_tree;\n+ gimple *stmt_to_print = NULL;\n+\n+ if (wi::neg_p (bump))\n {\n- enum tree_code code = PLUS_EXPR;\n- tree bump_tree;\n- gimple *stmt_to_print = NULL;\n+ code = MINUS_EXPR;\n+ bump = -bump;\n+ }\n \n- /* If the basis name and the candidate's LHS have incompatible\n-\t types, introduce a cast. */\n- if (!useless_type_conversion_p (target_type, TREE_TYPE (basis_name)))\n-\tbasis_name = introduce_cast_before_cand (c, target_type, basis_name);\n- if (wi::neg_p (bump))\n+ /* It is possible that the resulting bump doesn't fit in target_type.\n+ Abandon the replacement in this case. This does not affect\n+ siblings or dependents of C. */\n+ if (bump != wi::ext (bump, TYPE_PRECISION (target_type),\n+\t\t TYPE_SIGN (target_type)))\n+ return;\n+\n+ bump_tree = wide_int_to_tree (target_type, bump);\n+\n+ /* If the basis name and the candidate's LHS have incompatible types,\n+ introduce a cast. */\n+ if (!useless_type_conversion_p (target_type, TREE_TYPE (basis_name)))\n+ basis_name = introduce_cast_before_cand (c, target_type, basis_name);\n+\n+ if (dump_file && (dump_flags & TDF_DETAILS))\n+ {\n+ fputs (\"Replacing: \", dump_file);\n+ print_gimple_stmt (dump_file, c->cand_stmt, 0);\n+ }\n+\n+ if (bump == 0)\n+ {\n+ tree lhs = gimple_assign_lhs (c->cand_stmt);\n+ gassign *copy_stmt = gimple_build_assign (lhs, basis_name);\n+ gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);\n+ slsr_cand_t cc = c;\n+ gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));\n+ gsi_replace (&gsi, copy_stmt, false);\n+ c->cand_stmt = copy_stmt;\n+ while (cc->next_interp)\n \t{\n-\t code = MINUS_EXPR;\n-\t bump = -bump;\n+\t cc = lookup_cand (cc->next_interp);\n+\t cc->cand_stmt = copy_stmt;\n \t}\n-\n- bump_tree = wide_int_to_tree (target_type, bump);\n-\n if (dump_file && (dump_flags & TDF_DETAILS))\n+\tstmt_to_print = copy_stmt;\n+ }\n+ else\n+ {\n+ tree rhs1, rhs2;\n+ if (cand_code != NEGATE_EXPR) {\n+\trhs1 = gimple_assign_rhs1 (c->cand_stmt);\n+\trhs2 = gimple_assign_rhs2 (c->cand_stmt);\n+ }\n+ if (cand_code != NEGATE_EXPR\n+\t && ((operand_equal_p (rhs1, basis_name, 0)\n+\t && operand_equal_p (rhs2, bump_tree, 0))\n+\t || (operand_equal_p (rhs1, bump_tree, 0)\n+\t\t && operand_equal_p (rhs2, basis_name, 0))))\n \t{\n-\t fputs (\"Replacing: \", dump_file);\n-\t print_gimple_stmt (dump_file, c->cand_stmt, 0);\n+\t if (dump_file && (dump_flags & TDF_DETAILS))\n+\t {\n+\t fputs (\"(duplicate, not actually replacing)\", dump_file);\n+\t stmt_to_print = c->cand_stmt;\n+\t }\n \t}\n-\n- if (bump == 0)\n+ else\n \t{\n-\t tree lhs = gimple_assign_lhs (c->cand_stmt);\n-\t gassign *copy_stmt = gimple_build_assign (lhs, basis_name);\n \t gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);\n \t slsr_cand_t cc = c;\n-\t gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));\n-\t gsi_replace (&gsi, copy_stmt, false);\n-\t c->cand_stmt = copy_stmt;\n+\t gimple_assign_set_rhs_with_ops (&gsi, code, basis_name, bump_tree);\n+\t update_stmt (gsi_stmt (gsi));\n+\t c->cand_stmt = gsi_stmt (gsi);\n \t while (cc->next_interp)\n \t {\n \t cc = lookup_cand (cc->next_interp);\n-\t cc->cand_stmt = copy_stmt;\n+\t cc->cand_stmt = gsi_stmt (gsi);\n \t }\n \t if (dump_file && (dump_flags & TDF_DETAILS))\n-\t stmt_to_print = copy_stmt;\n+\t stmt_to_print = gsi_stmt (gsi);\n \t}\n- else\n-\t{\n-\t tree rhs1, rhs2;\n-\t if (cand_code != NEGATE_EXPR) {\n-\t rhs1 = gimple_assign_rhs1 (c->cand_stmt);\n-\t rhs2 = gimple_assign_rhs2 (c->cand_stmt);\n-\t }\n-\t if (cand_code != NEGATE_EXPR\n-\t && ((operand_equal_p (rhs1, basis_name, 0)\n-\t\t && operand_equal_p (rhs2, bump_tree, 0))\n-\t\t || (operand_equal_p (rhs1, bump_tree, 0)\n-\t\t && operand_equal_p (rhs2, basis_name, 0))))\n-\t {\n-\t if (dump_file && (dump_flags & TDF_DETAILS))\n-\t\t{\n-\t\t fputs (\"(duplicate, not actually replacing)\", dump_file);\n-\t\t stmt_to_print = c->cand_stmt;\n-\t\t}\n-\t }\n-\t else\n-\t {\n-\t gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);\n-\t slsr_cand_t cc = c;\n-\t gimple_assign_set_rhs_with_ops (&gsi, code,\n-\t\t\t\t\t basis_name, bump_tree);\n-\t update_stmt (gsi_stmt (gsi));\n- c->cand_stmt = gsi_stmt (gsi);\n-\t while (cc->next_interp)\n-\t\t{\n-\t\t cc = lookup_cand (cc->next_interp);\n-\t\t cc->cand_stmt = gsi_stmt (gsi);\n-\t\t}\n-\t if (dump_file && (dump_flags & TDF_DETAILS))\n-\t\tstmt_to_print = gsi_stmt (gsi);\n-\t }\n-\t}\n+ }\n \n- if (dump_file && (dump_flags & TDF_DETAILS))\n-\t{\n-\t fputs (\"With: \", dump_file);\n-\t print_gimple_stmt (dump_file, stmt_to_print, 0);\n-\t fputs (\"\\n\", dump_file);\n- \t}\n+ if (dump_file && (dump_flags & TDF_DETAILS))\n+ {\n+ fputs (\"With: \", dump_file);\n+ print_gimple_stmt (dump_file, stmt_to_print, 0);\n+ fputs (\"\\n\", dump_file);\n }\n }\n \nIndex: gcc/testsuite/gcc.c-torture/execute/pr81503.c\n===================================================================\n--- gcc/testsuite/gcc.c-torture/execute/pr81503.c\t(nonexistent)\n+++ gcc/testsuite/gcc.c-torture/execute/pr81503.c\t(working copy)\n@@ -0,0 +1,15 @@\n+unsigned short a = 41461;\n+unsigned short b = 3419;\n+int c = 0;\n+\n+void foo() {\n+ if (a + b * ~(0 != 5))\n+ c = -~(b * ~(0 != 5)) + 2147483647;\n+}\n+\n+int main() {\n+ foo();\n+ if (c != 2147476810)\n+ return -1;\n+ return 0;\n+}\n", "prefixes": [ "v3" ] }