get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/808808/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 808808,
    "url": "http://patchwork.ozlabs.org/api/patches/808808/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/alpine.DEB.2.20.1709011629490.23876@digraph.polyomino.org.uk/",
    "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": "<alpine.DEB.2.20.1709011629490.23876@digraph.polyomino.org.uk>",
    "list_archive_url": null,
    "date": "2017-09-01T16:30:29",
    "name": "Fix excess precision handling of compound assignments (PR c/82071)",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "091a27c217eee9b9b38085031cc94eb24736c3a2",
    "submitter": {
        "id": 4349,
        "url": "http://patchwork.ozlabs.org/api/people/4349/?format=api",
        "name": "Joseph Myers",
        "email": "joseph@codesourcery.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/alpine.DEB.2.20.1709011629490.23876@digraph.polyomino.org.uk/mbox/",
    "series": [
        {
            "id": 1070,
            "url": "http://patchwork.ozlabs.org/api/series/1070/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=1070",
            "date": "2017-09-01T16:30:29",
            "name": "Fix excess precision handling of compound assignments (PR c/82071)",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/1070/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/808808/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/808808/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<gcc-patches-return-461306-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-461306-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=\"PeOEpE7g\"; 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 3xkPr71Jn2z9t2x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 02:30:57 +1000 (AEST)",
            "(qmail 62876 invoked by alias); 1 Sep 2017 16:30:46 -0000",
            "(qmail 62846 invoked by uid 89); 1 Sep 2017 16:30:46 -0000",
            "from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131)\n\tby sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with\n\tESMTP; Fri, 01 Sep 2017 16:30:41 +0000",
            "from nat-ies.mentorg.com ([192.94.31.2]\n\thelo=svr-ies-mbx-01.mgc.mentorg.com)\tby relay1.mentorg.com\n\twith esmtp id 1dnoq6-00020a-5T from joseph_myers@mentor.com\n\tfor gcc-patches@gcc.gnu.org; Fri, 01 Sep 2017 09:30:38 -0700",
            "from digraph.polyomino.org.uk (137.202.0.87) by\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft\n\tSMTP Server (TLS) id 15.0.1263.5; Fri, 1 Sep 2017 17:30:34 +0100",
            "from jsm28 (helo=localhost)\tby digraph.polyomino.org.uk with\n\tlocal-esmtp (Exim 4.86_2)\t(envelope-from\n\t<joseph@codesourcery.com>)\tid 1dnopx-0006Ye-Nq\tfor\n\tgcc-patches@gcc.gnu.org; Fri, 01 Sep 2017 16:30:29 +0000"
        ],
        "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:date\n\t:from:to:subject:message-id:mime-version:content-type; q=dns; s=\n\tdefault; b=UitIyzwC94/MivGvDZ3hornqQlJNgQZGBmBN5SzInluFDRoMluHQG\n\tcDEYzAI2B7Jom8DEdjPplo9vPRC/xW7l9LqzPeMl7w7T79yUg3rVA7p934w1kJJV\n\tIfSkNvhmDH+j8YJK2yJA25u9L0sp0iWhYS6AxBT+G43dXad/zLxw2E=",
        "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:date\n\t:from:to:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=RZprDquK+/9BL6YU1DbeqDfWFLg=; b=PeOEpE7gO7bvKXMy4ESr\n\tQNdwbUNrfe6uvr5H/3ULXxAEOnB7eylvRgleck7jUYxS6pLe0DjTXvnHydnsrT2r\n\thYC16BNmZKFbpkieft2BUZ7F3AXzaBmIWBd8wTnDGIbwGuvNvDcbn+zDk3YL4wIg\n\tWKZQdad9Ky0dHgyAlxlksU0=",
        "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.2 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tRCVD_IN_DNSWL_NONE, SPF_PASS,\n\tURIBL_RED autolearn=ham version=3.3.2 spammy=",
        "X-HELO": "relay1.mentorg.com",
        "Date": "Fri, 1 Sep 2017 16:30:29 +0000",
        "From": "Joseph Myers <joseph@codesourcery.com>",
        "To": "<gcc-patches@gcc.gnu.org>",
        "Subject": "Fix excess precision handling of compound assignments (PR c/82071)",
        "Message-ID": "<alpine.DEB.2.20.1709011629490.23876@digraph.polyomino.org.uk>",
        "User-Agent": "Alpine 2.20 (DEB 67 2015-01-07)",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "X-ClientProxiedBy": "svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To\n\tsvr-ies-mbx-01.mgc.mentorg.com (139.181.222.1)"
    },
    "content": "PR c/82071 reports how compound assignment operators such as += handle\nexcess precision inconsistently with the same operation done with a\nplain assignment and binary operator.\n\nThere were (at least) two problems with how compound assignments\nhandled excess precision.  The EXCESS_PRECISION_EXPR for an argument\nwith excess precision was removed too early, resulting in\nbuild_binary_op being called with an rhs operand whose type reflected\nthe evaluation format, so not having sufficient information to achieve\nthe intended semantics in all cases, and then the code called\nc_fully_fold on the results of build_binary_op without allowing for\nthe possibility of an EXCESS_PRECISION_EXPR as the result, so leading\nto double rounding of the result (first to its semantic type, then to\nthe type of the LHS of the assignment) instead of the intended single\nrounding.\n\nThis patch fixes those problems by keeping EXCESS_PRECISION_EXPRs\nfurther through build_modify_expr (and build_atomic_assign which it\ncalls) and only removing them locally where appropriate.\n\nNote that while this patch should achieve *consistency*, that's\nconsistency with the understanding of C99 semantics that I originally\nintended to implement.  For the particular case in the testcase, C11\nsemantics (from N1531) differ from that understanding of C99\nsemantics, in that an implicit conversion of an integer to floating\npoint can have excess precision.  I intend to implement those C11\nsemantics separately (conditional on flag_isoc11) (which will also\nmean that building conditional expressions can produce a result with\nexcess precision even when the arguments lack excess precision, where\npreviously it could not), and not to close the bug until that is also\ndone.\n\nTested for x86_64-pc-linux-gnu.  Applied to mainline.\n\ngcc/c:\n2017-09-01  Joseph Myers  <joseph@codesourcery.com>\n\n\tPR c/82071\n\t* c-typeck.c (build_atomic_assign): Handle argument with excess\n\tprecision.  Ensure any EXCESS_PRECISION_EXPR is present in\n\targument passed to build_binary_op and convert_for_assignment but\n\tnot for call to c_fully_fold.\n\t(build_modify_expr): Do not remove EXCESS_PRECISION_EXPR early.\n\tEnsure build_binary_op is called with argument with original\n\tsemantic type.  Avoid calling c_fully_fold with an\n\tEXCESS_PRECISION_EXPR from build_binary_op.\n\ngcc/testsuite:\n2017-09-01  Joseph Myers  <joseph@codesourcery.com>\n\n\tPR c/82071\n\t* gcc.target/i386/excess-precision-7.c: New test.",
    "diff": "Index: gcc/c/c-typeck.c\n===================================================================\n--- gcc/c/c-typeck.c\t(revision 251561)\n+++ gcc/c/c-typeck.c\t(working copy)\n@@ -3919,7 +3919,9 @@ build_atomic_assign (location_t loc, tree lhs, enu\n   tree lhs_type = TREE_TYPE (lhs);\n   tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);\n   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);\n-  tree rhs_type = TREE_TYPE (rhs);\n+  tree rhs_semantic_type = TREE_TYPE (rhs);\n+  tree nonatomic_rhs_semantic_type;\n+  tree rhs_type;\n \n   gcc_assert (TYPE_ATOMIC (lhs_type));\n \n@@ -3933,6 +3935,15 @@ build_atomic_assign (location_t loc, tree lhs, enu\n      with a loop.  */\n   compound_stmt = c_begin_compound_stmt (false);\n \n+  /* Remove any excess precision (which is only present here in the\n+     case of compound assignments).  */\n+  if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)\n+    {\n+      gcc_assert (modifycode != NOP_EXPR);\n+      rhs = TREE_OPERAND (rhs, 0);\n+    }\n+  rhs_type = TREE_TYPE (rhs);\n+\n   /* Fold the RHS if it hasn't already been folded.  */\n   if (modifycode != NOP_EXPR)\n     rhs = c_fully_fold (rhs, false, NULL);\n@@ -3941,6 +3952,8 @@ build_atomic_assign (location_t loc, tree lhs, enu\n      the VAL temp variable to hold the RHS.  */\n   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);\n   nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);\n+  nonatomic_rhs_semantic_type = build_qualified_type (rhs_semantic_type,\n+\t\t\t\t\t\t      TYPE_UNQUALIFIED);\n   val = create_tmp_var_raw (nonatomic_rhs_type);\n   TREE_ADDRESSABLE (val) = 1;\n   TREE_NO_WARNING (val) = 1;\n@@ -4100,8 +4113,17 @@ cas_loop:\n   add_stmt (loop_label);\n \n   /* newval = old + val;  */\n+  if (rhs_type != rhs_semantic_type)\n+    val = build1 (EXCESS_PRECISION_EXPR, nonatomic_rhs_semantic_type, val);\n   rhs = build_binary_op (loc, modifycode, old, val, true);\n-  rhs = c_fully_fold (rhs, false, NULL);\n+  if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)\n+    {\n+      tree eptype = TREE_TYPE (rhs);\n+      rhs = c_fully_fold (TREE_OPERAND (rhs, 0), false, NULL);\n+      rhs = build1 (EXCESS_PRECISION_EXPR, eptype, rhs);\n+    }\n+  else\n+    rhs = c_fully_fold (rhs, false, NULL);\n   rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,\n \t\t\t\trhs, NULL_TREE, ic_assign, false, NULL_TREE,\n \t\t\t\tNULL_TREE, 0);\n@@ -5727,7 +5749,6 @@ build_modify_expr (location_t location, tree lhs,\n   tree result;\n   tree newrhs;\n   tree rhseval = NULL_TREE;\n-  tree rhs_semantic_type = NULL_TREE;\n   tree lhstype = TREE_TYPE (lhs);\n   tree olhstype = lhstype;\n   bool npc;\n@@ -5754,12 +5775,6 @@ build_modify_expr (location_t location, tree lhs,\n \n   is_atomic_op = really_atomic_lvalue (lhs);\n \n-  if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)\n-    {\n-      rhs_semantic_type = TREE_TYPE (rhs);\n-      rhs = TREE_OPERAND (rhs, 0);\n-    }\n-\n   newrhs = rhs;\n \n   if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)\n@@ -5794,8 +5809,14 @@ build_modify_expr (location_t location, tree lhs,\n \t     that modify LHS.  */\n \t  if (TREE_SIDE_EFFECTS (rhs))\n \t    {\n-\t      newrhs = save_expr (rhs);\n+\t      if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)\n+\t\tnewrhs = save_expr (TREE_OPERAND (rhs, 0));\n+\t      else\n+\t\tnewrhs = save_expr (rhs);\n \t      rhseval = newrhs;\n+\t      if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)\n+\t\tnewrhs = build1 (EXCESS_PRECISION_EXPR, TREE_TYPE (rhs),\n+\t\t\t\t newrhs);\n \t    }\n \t  newrhs = build_binary_op (location,\n \t\t\t\t    modifycode, lhs, newrhs, true);\n@@ -5810,7 +5831,10 @@ build_modify_expr (location_t location, tree lhs,\n     {\n       /* Check if we are modifying an Objective-C property reference;\n \t if so, we need to generate setter calls.  */\n-      result = objc_maybe_build_modify_expr (lhs, newrhs);\n+      if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)\n+\tresult = objc_maybe_build_modify_expr (lhs, TREE_OPERAND (newrhs, 0));\n+      else\n+\tresult = objc_maybe_build_modify_expr (lhs, newrhs);\n       if (result)\n \tgoto return_result;\n \n@@ -5887,6 +5911,12 @@ build_modify_expr (location_t location, tree lhs,\n \n   if (!(is_atomic_op && modifycode != NOP_EXPR))\n     {\n+      tree rhs_semantic_type = NULL_TREE;\n+      if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)\n+\t{\n+\t  rhs_semantic_type = TREE_TYPE (newrhs);\n+\t  newrhs = TREE_OPERAND (newrhs, 0);\n+\t}\n       npc = null_pointer_constant_p (newrhs);\n       newrhs = c_fully_fold (newrhs, false, NULL);\n       if (rhs_semantic_type)\nIndex: gcc/testsuite/gcc.target/i386/excess-precision-7.c\n===================================================================\n--- gcc/testsuite/gcc.target/i386/excess-precision-7.c\t(nonexistent)\n+++ gcc/testsuite/gcc.target/i386/excess-precision-7.c\t(working copy)\n@@ -0,0 +1,41 @@\n+/* Excess precision tests.  Test C99 semantics for conversions from\n+   integers to floating point: no excess precision for either explicit\n+   or implicit conversions.  */\n+/* { dg-do run } */\n+/* { dg-options \"-std=c99 -mfpmath=387 -fexcess-precision=standard\" } */\n+\n+extern void abort (void);\n+extern void exit (int);\n+\n+int\n+main (void)\n+{\n+  float f = 1.0f;\n+  int i;\n+\n+  i = 0x10001234;\n+  if ((float) i != 0x10001240)\n+    abort ();\n+\n+  i = 0x10001234;\n+  i += f;\n+  if (i != 0x10001241)\n+    abort ();\n+\n+  i = 0x10001234;\n+  i += 1.0f;\n+  if (i != 0x10001241)\n+    abort ();\n+\n+  i = 0x10001234;\n+  i = i + f;\n+  if (i != 0x10001241)\n+    abort ();\n+\n+  i = 0x10001234;\n+  i = i + 1.0f;\n+  if (i != 0x10001241)\n+    abort ();\n+\n+  exit (0);\n+}\n",
    "prefixes": []
}