{"id":2229328,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229328/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/afBcnhD47GSb42_u@tucnak/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","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},"msgid":"<afBcnhD47GSb42_u@tucnak>","date":"2026-04-28T07:07:10","name":"range-op-float: Fix ICE on undefined_p ranges [PR125039]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"57fdec0e7147f917bf6333b11849d06be27108c2","submitter":{"id":671,"url":"http://patchwork.ozlabs.org/api/1.1/people/671/?format=json","name":"Jakub Jelinek","email":"jakub@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/afBcnhD47GSb42_u@tucnak/mbox/","series":[{"id":501770,"url":"http://patchwork.ozlabs.org/api/1.1/series/501770/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501770","date":"2026-04-28T07:07:10","name":"range-op-float: Fix ICE on undefined_p ranges [PR125039]","version":1,"mbox":"http://patchwork.ozlabs.org/series/501770/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229328/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229328/checks/","tags":{},"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=IdMyJdT8;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::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=IdMyJdT8","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\n [IPv6:2620:52:6:3111::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 4g4WjK5GYXz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 17:07:48 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 42C734BABF00\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 07:07:46 +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 A1E194B9DB42\n for <gcc-patches@gcc.gnu.org>; Tue, 28 Apr 2026 07:07:18 +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-322-n0dlEWXJMPq-QjnZqxINBA-1; Tue,\n 28 Apr 2026 03:07:15 -0400","from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\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 DEA0319560A3; Tue, 28 Apr 2026 07:07:13 +0000 (UTC)","from tucnak.zalov.cz (unknown [10.44.34.21])\n by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 4630A300757C; Tue, 28 Apr 2026 07:07:13 +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 63S77A29296384\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 28 Apr 2026 09:07:10 +0200","(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63S77Aok296383;\n Tue, 28 Apr 2026 09:07:10 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 42C734BABF00","OpenDKIM Filter v2.11.0 sourceware.org A1E194B9DB42"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org A1E194B9DB42","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org A1E194B9DB42","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777360038; cv=none;\n b=S3nagkRJ8B/u284FcIptKoeU5bTEtRiLh1FOQwUAU3Mp+wgmePmxvljWiLEIrt48xR4VJdgMTcDfVsFGCiBJVAWTD7uVkYjTp/rHDx7yMy9Ebr+8CqMohuKHElo98nWhiXBfwAKQI+grF/7oA3EJEGMPsoAXL3iivK+kUB/017w=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777360038; c=relaxed/simple;\n bh=HqeGJIgo+KdGhifLFiP3Ieh3afZ3MvS39HGpI6aPB+c=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=dsfQPxoc1TB4HboGYifnpWg1ULsuAwG+Yhf5GztfuE8tYOH2nIVcSxaMrlbJ21ogXbFa099Y4oUHAJ04kVJbFeYWcNbkXXVwxqpwIeypkmedHjcQcQwH11X+4ZMW2Z2R2neC//yho+V5QUWmiLaguv23u9jfIOc/UGdvQGX6hFQ=","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=1777360038;\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=GKAIxRwryvn1p6FsE4rMADAdijiQrjkLXzUi/zvf5yE=;\n b=IdMyJdT8SW/FXwfNwdRR7sbX86IGZvKvOOl8rfm/LKnWz3uRKzCaRGXF4Qu6V6YIXcAYej\n Qb8y3jjzHTW9T8NsG8LUXbF2fnaHr6HCseQcWwOqe0Hn1onw4Z/FtzwbjoLcnHlLq0uuyR\n OB/jjsH5IFirp9M2/ki923SNk/wBD34=","X-MC-Unique":"n0dlEWXJMPq-QjnZqxINBA-1","X-Mimecast-MFC-AGG-ID":"n0dlEWXJMPq-QjnZqxINBA_1777360034","Date":"Tue, 28 Apr 2026 09:07:10 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Richard Biener <rguenther@suse.de>, Andrew MacLeod <amacleod@redhat.com>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] range-op-float: Fix ICE on undefined_p ranges [PR125039]","Message-ID":"<afBcnhD47GSb42_u@tucnak>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.4","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"IN5NODXw5zJvuyC-9R_duMbUtL1J-iqPjIBZo3XW3sw_1777360034","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 at -O1 since r14-4153.\nlower_bound/upper_bound methods on frange (and others) assert\nthey aren't called on undefined_p () ranges, because such ranges\ndon't really have any lower or upper bound.\nMost fold_range virtual methods call empty_range_varying early\nwhich checks if the operand ranges aren't undefined and in that case\nreturn true and set r to varying, and then can safely use\nlower_bound/upper_bound etc.\nNow, operator_not_equal::fold_range did that until r14-4152 indirectly,\nby calling it in frelop_early_resolve which it called unconditionally.\nr14-4153 changed it not to call frelop_early_resolve in some cases\nbecause it could misbehave as mentioned in the comment.\nfrelop_early_resolve has 3 conditionals it handles.\n  if (!maybe_isnan (op1, op2) && relation_union (rel, my_rel) == my_rel)\ndoesn't apply for this case, because the\n  if (rel == VREL_EQ && maybe_isnan (op1, op2))\ncondition means maybe_isnan (op1, op2) will be true.\n  if (relation_intersect (rel, my_rel) == VREL_UNDEFINED)\nis the condition which r14-4153 wanted to avoid.  And finally\n  if (empty_range_varying (r, type, op1, op2))\nis the condition the following patch readds, so that we don't ICE on those.\n\nBootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk,\nand later 16.2, 15.3 and 14.4?\n\n2026-04-27  Jakub Jelinek  <jakub@redhat.com>\n\n\tPR tree-optimization/125039\n\t* range-op-float.cc (operator_not_equal::fold_range): Call\n\tempty_range_varying when not calling frelop_early_resolve.\n\n\t* gcc.c-torture/compile/pr125039.c: New test.\n\n\n\tJakub","diff":"--- gcc/range-op-float.cc.jj\t2026-03-27 10:17:14.477325142 +0100\n+++ gcc/range-op-float.cc\t2026-04-27 15:22:16.383532968 +0200\n@@ -759,6 +759,9 @@ operator_not_equal::fold_range (irange &\n       // Avoid frelop_early_resolve() below as it could fold to FALSE\n       // without regards to NANs.  This would be incorrect if trying\n       // to fold x_5 != x_5 without prior knowledge of NANs.\n+      // Still, if either operand is undefined, return VARYING.\n+      if (empty_range_varying (r, type, op1, op2))\n+\treturn true;\n     }\n   else if (frelop_early_resolve (r, type, op1, op2, trio, VREL_NE))\n     return true;\n--- gcc/testsuite/gcc.c-torture/compile/pr125039.c.jj\t2026-04-27 15:23:49.893940823 +0200\n+++ gcc/testsuite/gcc.c-torture/compile/pr125039.c\t2026-04-27 15:23:19.196463488 +0200\n@@ -0,0 +1,12 @@\n+/* PR tree-optimization/125039 */\n+\n+void\n+foo ()\n+{\n+  double b = b, c = c;\n+  if (c)\n+    c = -c;\n+  double d = b == c ? b : c;\n+  if (c != d)\n+    foo ();\n+}\n","prefixes":[]}