Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2174160/?format=api
{ "id": 2174160, "url": "http://patchwork.ozlabs.org/api/patches/2174160/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/aT_L4MhTnd-gdxi9@tucnak/", "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": "<aT_L4MhTnd-gdxi9@tucnak>", "list_archive_url": null, "date": "2025-12-15T08:50:40", "name": "simplify-rtx: Fix up (ne (ior (ne x 0) y) 0) simplification [PR123114]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "01098c7580966215821191383e8e01e037438e82", "submitter": { "id": 671, "url": "http://patchwork.ozlabs.org/api/people/671/?format=api", "name": "Jakub Jelinek", "email": "jakub@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/aT_L4MhTnd-gdxi9@tucnak/mbox/", "series": [ { "id": 485363, "url": "http://patchwork.ozlabs.org/api/series/485363/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=485363", "date": "2025-12-15T08:50:40", "name": "simplify-rtx: Fix up (ne (ior (ne x 0) y) 0) simplification [PR123114]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/485363/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2174160/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2174160/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=debk5rps;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=debk5rps", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com", "sourceware.org; spf=pass smtp.mailfrom=redhat.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dVDLn5kPLz1y15\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 15 Dec 2025 19:51:28 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id F10B14BA2E04\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 15 Dec 2025 08:51:25 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 5598F4BA2E04\n for <gcc-patches@gcc.gnu.org>; Mon, 15 Dec 2025 08:50:48 +0000 (GMT)", "from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-02HXkWGvPsiG15GThajwYA-1; Mon,\n 15 Dec 2025 03:50:45 -0500", "from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id DFE04195FCEF; Mon, 15 Dec 2025 08:50:44 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.45.225.148])\n by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 4B3041956056; Mon, 15 Dec 2025 08:50:44 +0000 (UTC)", "from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 5BF8ofxs2230642\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Mon, 15 Dec 2025 09:50:41 +0100", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 5BF8ofVd2230641;\n Mon, 15 Dec 2025 09:50:41 +0100" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org F10B14BA2E04", "OpenDKIM Filter v2.11.0 sourceware.org 5598F4BA2E04" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 5598F4BA2E04", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 5598F4BA2E04", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765788648; cv=none;\n b=E/0Gj6aWbZ2DTU/YMhqF5u5BgQgyQZkltNSmlWfSO6EA9VOj9Z7P2xjEyeECBNwbQHZyKpWiYst8rizzbu7jxFxGcWYQ48EIS9lbLJTrA5XBVlomCnUitQDa9k9oMJZ2Qt8lmpoaj7JsDgdWdo1Gud5HeAWFHGip9MGcP8JIWpI=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1765788648; c=relaxed/simple;\n bh=8nehLqMQY16eK96cDN4gG0aah+lssXa0xraKIF5l/pM=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=HaJ5/pCm5463FAUCq4u6Dc++2+jyRVOMT0swcnsfjkEfGkAup0bTL+H0A5Ur3odZsbFT7Bt8b7E1auHYr3iVvSeB6RQvnLAhO11Xg5OA7s9kGekBzC9ZimVbslVauPq0AAzMRcmiJL0xB4Bwcp3RGkwq6j+sSZnVlx+iM2ngZns=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1765788647;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=3GEFfD2hzYmKK8svaYJ+pHPDG3Yp8dN0mUYu8kiQQeI=;\n b=debk5rpsfPCzer+QrOR5zX/sxtw/JOjOFEvu91vd0LftuuBX2WlVdS7RLNW497F7jXClmb\n SyCPAjdO0gll/LgBKUZYRrFiVPRpqDo7YWzT5FQih1FRRjd6hko73bVNl8dnS1mEZDZy60\n 3S7G7iMS40GUV1bopSP1P4tLfzHH7+A=", "X-MC-Unique": "02HXkWGvPsiG15GThajwYA-1", "X-Mimecast-MFC-AGG-ID": "02HXkWGvPsiG15GThajwYA_1765788645", "Date": "Mon, 15 Dec 2025 09:50:40 +0100", "From": "Jakub Jelinek <jakub@redhat.com>", "To": "Jeff Law <jeffreyalaw@gmail.com>", "Cc": "gcc-patches@gcc.gnu.org", "Subject": "[PATCH] simplify-rtx: Fix up (ne (ior (ne x 0) y) 0) simplification\n [PR123114]", "Message-ID": "<aT_L4MhTnd-gdxi9@tucnak>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.17", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "9Aiyxu4ZUxlY9qkJVGnkM9WhGLNp3rdKrF4K3W6rUYU_1765788645", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Reply-To": "Jakub Jelinek <jakub@redhat.com>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "Hi!\n\nThe following testcase ICEs on x86_64-linux since the PR52345\n(ne (ior (ne x 0) y) 0) simplification was (slightly) fixed.\nIt wants to optimize\n (set (reg/i:DI 10 a0)\n (ne:DI (ior:DI (ne:DI (reg:DI 151 [ a ])\n (const_int 0 [0]))\n (reg:DI 152 [ b ]))\n (const_int 0 [0])))\nbut doesn't check important property of that, in particular\nthat the mode of the inner NE operand is the same as the\nmode of the inner NE.\nThe following testcase has\n(set (reg:CCZ 17 flags)\n (compare:CCZ (ior:QI (ne:QI (reg/v:SI 104 [ c ])\n (const_int 0 [0]))\n (reg:QI 98 [ _5 ]))\n (const_int 0 [0])))\nwhere cmp_mode is QImode, but the mode of the inner NE operand\nis SImode instead, and it attempts to create\n (ne:CCZ (ior:QI (reg/v:SI 104 [ c ]) (reg:QI 98 [ _5 ])) (const_int 0))\nwhich obviously crashes later on.\n\nThe following patch fixes it by checking the mode of the inner NE operand\nand also by using CONST0_RTX (cmp_mode) instead of CONST0_RTX (mode)\nbecause that is the mode of the other operand, not mode which is the\nmode of the outer comparison (though, guess for most modes it will still\nbe const0_rtx).\n\nI guess for mode mismatches we could arbitrarily choose some extension (zero\nor sign) and extend the narrower mode to the wider mode, but I doubt that it\nwould ever match on any target. But even then we'd need to limit it, we\nwouldn't want to deal with another mode class (say floating point\ncomparisons), and dunno about vector modes etc.\n\nBootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?\n\n2025-12-13 Jakub Jelinek <jakub@redhat.com>\n\n\tPR rtl-optimization/123114\n\t* simplify-rtx.cc (simplify_context::simplify_relational_operation):\n\tVerify XEXP (XEXP (op0, 0), 0) mode and use CONST0_RTX (cmp_mode)\n\tinstead of CONST0_RTX (mode).\n\n\t* gcc.dg/pr123114.c: New test.\n\n\n\tJakub", "diff": "--- gcc/simplify-rtx.cc.jj\t2025-12-09 10:18:55.437229339 +0100\n+++ gcc/simplify-rtx.cc\t2025-12-13 23:04:14.672186706 +0100\n@@ -6509,8 +6509,9 @@ simplify_context::simplify_relational_op\n \t /* only enters if op1 is 0 */\n \t /* Verify IOR operand is NE */\n \t && GET_CODE (XEXP (op0, 0)) == NE\n+\t && GET_MODE (XEXP (XEXP (op0, 0), 0)) == cmp_mode\n \t /* Verify second NE operand is 0 */\n-\t && XEXP (XEXP (op0, 0), 1) == CONST0_RTX (mode))\n+\t && XEXP (XEXP (op0, 0), 1) == CONST0_RTX (cmp_mode))\n \t{\n \t rtx t = gen_rtx_IOR (cmp_mode, XEXP (XEXP (op0, 0), 0), XEXP (op0, 1));\n \t t = gen_rtx_fmt_ee (code, mode, t, CONST0_RTX (mode));\n--- gcc/testsuite/gcc.dg/pr123114.c.jj\t2025-12-13 23:13:53.528178273 +0100\n+++ gcc/testsuite/gcc.dg/pr123114.c\t2025-12-13 23:13:25.964657498 +0100\n@@ -0,0 +1,21 @@\n+/* PR rtl-optimization/123114 */\n+/* { dg-do compile } */\n+/* { dg-options \"-O3 -fno-tree-vrp\" } */\n+\n+volatile int a, b, g;\n+unsigned short e;\n+int f;\n+\n+int\n+main ()\n+{\n+ int c, d;\n+ while (a)\n+ {\n+ c = e = b << 2;\n+ d = f;\n+ g = (c <= 0 && d) || c ? 0 : d;\n+ a = g;\n+ }\n+ return 0;\n+}\n", "prefixes": [] }