{"id":2222987,"url":"http://patchwork.ozlabs.org/api/patches/2222987/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/ad3qTveCIFUtTGLg@tucnak/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<ad3qTveCIFUtTGLg@tucnak>","list_archive_url":null,"date":"2026-04-14T07:18:38","name":"bitintlower: Handle BIT_FIELD_REF load [PR124826]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"581c9ca9af23982cbdfca8226d0b5cd19bcb77f0","submitter":{"id":671,"url":"http://patchwork.ozlabs.org/api/people/671/?format=json","name":"Jakub Jelinek","email":"jakub@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/ad3qTveCIFUtTGLg@tucnak/mbox/","series":[{"id":499791,"url":"http://patchwork.ozlabs.org/api/series/499791/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499791","date":"2026-04-14T07:18:38","name":"bitintlower: Handle BIT_FIELD_REF load [PR124826]","version":1,"mbox":"http://patchwork.ozlabs.org/series/499791/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222987/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222987/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=e9zn32ox;\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=e9zn32ox","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 4fvwd36rsvz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 17:19:18 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id BB2B14BA2E13\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 07:19:16 +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 42AD14BA2E0D\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 07:18:47 +0000 (GMT)","from mx-prod-mc-05.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-578-P87bFQEdPI2B9_X439FzlA-1; Tue,\n 14 Apr 2026 03:18:43 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 5F4CF19560AD; Tue, 14 Apr 2026 07:18:42 +0000 (UTC)","from tucnak.zalov.cz (unknown [10.44.33.129])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id CD98B180035F; Tue, 14 Apr 2026 07:18:41 +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 63E7IcIr2951762\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 14 Apr 2026 09:18:38 +0200","(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63E7IcZ22951761;\n Tue, 14 Apr 2026 09:18:38 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org BB2B14BA2E13","OpenDKIM Filter v2.11.0 sourceware.org 42AD14BA2E0D"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 42AD14BA2E0D","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 42AD14BA2E0D","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776151127; cv=none;\n b=n8TI//5UfdSpgX6UmQZahqoS9V7qta2SncEn5viCOB2mZ60eWdaCyiibjzANLlrJ5UUFRL/flUTo37ZjUpR4xKKjk0hLfr0YLbIUnLMEXLmFNcOTZfXZCdZE5Rr1Ba6tnUqMv0q9fIdf4KU31PgGW4JoHX/TOKpUoA5O94R8K80=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776151127; c=relaxed/simple;\n bh=mD9rcbRem7YNSfQRVV7HLROKAriv4I4QQcqLo3hznx8=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=IxIyvm2PZ++TVfTdXR5IEBg1riHJO9UZ0iHGjl1qd2yF8nk+N8iV2h3yu5ePJUiJbkRywzSfQLcKHb67iVNtG0Md5p/3+QkgFcVgqSwb1ERK38DdiclaUhtuZIqtzqkFsN5FWzB9yJ2Cb3dF8lBlZurItZq/qYhxV0Y3Ipp1uSU=","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=1776151126;\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=mM4Rhy9HVcchBzi4dYhDieshlYstBd8aOkkjog0F1/E=;\n b=e9zn32oxRPyQBqjdZNmHrETBHhugKTImV0i1JXY3XGrWt/M0FHSlQgXdyp3y4hC2+Vm66I\n cYzM4XSSHGSkPupqRn+eZo4qsFonwQxQBW5/cRYFgD0bBpcsQWUuoUE42eyCoTWT20l64z\n CPzJniyQ24md7hOOfNzeAYDf9toTF+g=","X-MC-Unique":"P87bFQEdPI2B9_X439FzlA-1","X-Mimecast-MFC-AGG-ID":"P87bFQEdPI2B9_X439FzlA_1776151122","Date":"Tue, 14 Apr 2026 09:18:38 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Richard Biener <rguenther@suse.de>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] bitintlower: Handle BIT_FIELD_REF load [PR124826]","Message-ID":"<ad3qTveCIFUtTGLg@tucnak>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"Bof-lk0qEf8ZaRtsnBmycF38s3crLP0z5juKy774SS0_1776151122","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 ends up with a BIT_FIELD_REF from a VECTOR_TYPE union\nmember to _BitInt(256).  gimple-lower-bitint.cc already contains code to\nhandle BIT_FIELD_REFs with SSA_NAME first operand to BITINT_TYPE (for\nconstant index limb access by adjusting the BIT_FIELD_REF to use different\nbitsize and index, for variable index (huge _BitInt with limbs accessed in a loop)\nby forcing the SSA_NAME into memory), but that doesn't trigger here, because\ngimple_assign_load_p predicate is true on it and so it is handled as load\nand not BIT_FIELD_REF.  Anyway, the problem is that we end up with\n_7 = VIEW_CONVERT_EXPR<unsigned long[4]>(BIT_FIELD_REF <u.v, 256, 0>)[_2];\nwhich tree-cfg.cc verifier doesn't like because BIT_FIELD_REF is not\ntoplevel reference in there.  The following patch just strips the\nBIT_FIELD_REF away if it has zero bit offset, that is the only case I've\nmanaged to reproduce, and in that case we are still later on using VCE to\nconvert to array and using ARRAY_REF on that.  If offset could be non-zero\nbut multiple of BITS_PER_UNIT, another approach would be to replace\nBIT_FIELD_REF with a MEM_REF.  Anyway, as I haven't managed to reproduce\nit with anything but 0, the following patch is enough.\n\nBootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?\n\n2026-04-14  Jakub Jelinek  <jakub@redhat.com>\n\n\tPR tree-optimization/124826\n\t* gimple-lower-bitint.cc (bitint_large_huge::handle_load): Look through\n\tBIT_FIELD_REF with zero bit offset.\n\n\t* gcc.dg/bitint-128.c: New test.\n\n\n\tJakub","diff":"--- gcc/gimple-lower-bitint.cc.jj\t2026-03-27 10:17:14.164330250 +0100\n+++ gcc/gimple-lower-bitint.cc\t2026-04-13 18:41:02.149286578 +0200\n@@ -1985,6 +1985,10 @@ bitint_large_huge::handle_load (gimple *\n   edge eh_edge = NULL;\n   gimple *g;\n \n+  if (TREE_CODE (rhs1) == BIT_FIELD_REF\n+      && integer_zerop (TREE_OPERAND (rhs1, 2)))\n+    rhs1 = TREE_OPERAND (rhs1, 0);\n+\n   if (eh)\n     {\n       edge_iterator ei;\n--- gcc/testsuite/gcc.dg/bitint-128.c.jj\t2026-04-13 18:49:40.292517820 +0200\n+++ gcc/testsuite/gcc.dg/bitint-128.c\t2026-04-13 18:49:04.001131057 +0200\n@@ -0,0 +1,27 @@\n+/* PR tree-optimization/124826 */\n+/* { dg-do compile { target bitint } } */\n+/* { dg-options \"-O2\" } */\n+\n+typedef float V __attribute__((vector_size (16 * sizeof (float))));\n+\n+union {\n+#if __BITINT_MAXWIDTH__ >= 256\n+  _BitInt(256) b;\n+#endif\n+  V v;\n+} u;\n+\n+void\n+foo (int c)\n+{\n+  u.v -= c ? 0.f : 1.f;\n+#if __BITINT_MAXWIDTH__ >= 256\n+  u.b *= c;\n+#endif\n+}\n+\n+int\n+main ()\n+{\n+  foo (2);\n+}\n","prefixes":[]}