{"id":2230051,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230051/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/afGiA9mbF4L3VzTH@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":"<afGiA9mbF4L3VzTH@tucnak>","date":"2026-04-29T06:15:31","name":"bitintlower: Padding bit fixes, part 6 [PR123635]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6172b95798e64c70701c2cda9ab6c4f597f90948","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/afGiA9mbF4L3VzTH@tucnak/mbox/","series":[{"id":501992,"url":"http://patchwork.ozlabs.org/api/1.1/series/501992/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501992","date":"2026-04-29T06:15:31","name":"bitintlower: Padding bit fixes, part 6 [PR123635]","version":1,"mbox":"http://patchwork.ozlabs.org/series/501992/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230051/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230051/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=BgEluo5x;\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=BgEluo5x","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.129.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 4g56WF2Cw4z1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 16:16:09 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 3DF004BB3BBA\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 06:16:07 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id 2FBB34BA7999\n for <gcc-patches@gcc.gnu.org>; Wed, 29 Apr 2026 06:15:40 +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-125-j5RB7i8zNbaPUaOJjEiDUg-1; Wed,\n 29 Apr 2026 02:15:36 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\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 1A1E01956088; Wed, 29 Apr 2026 06:15:35 +0000 (UTC)","from tucnak.zalov.cz (unknown [10.44.34.21])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 6E8BF19560B6; Wed, 29 Apr 2026 06:15:34 +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 63T6FV8I390587\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Wed, 29 Apr 2026 08:15:31 +0200","(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63T6FVOR390586;\n Wed, 29 Apr 2026 08:15:31 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 3DF004BB3BBA","OpenDKIM Filter v2.11.0 sourceware.org 2FBB34BA7999"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 2FBB34BA7999","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 2FBB34BA7999","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777443340; cv=none;\n b=Y/5IOtDF5pX6fW2b3mVEQ8u6py8JSwn+pTsAbqNyNQHw106d8ViKvlGl6qKOD+2f91yWdcxGghXxB7sJWHUnL1CM2UZxk4+BlmM/5N5VnQWBj6DVK/qAhtzXmI2WL3jeTAaReJXiceB773ttUnn4sQoozemYIeBhuq80gvT0oW0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777443340; c=relaxed/simple;\n bh=WVMhgNlF5DH2br1RO2FV4qQJy6FvNHGVBmjWS8KTAkQ=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=QCBgwqCj2SVY4LccWhDi7RjFfsurWXRUF+7480j7zwC80X8qwZjMllWNlJjI1QLOhUxd5UfQrRccdOcFKtdV3j233wFZMjxJbiLidu6ni1xYxcdp22PArJKn0Gv6oDxYwJjHKyiDG6JJW9jleiLhoaWIQFe9izYSTky2/9tWsHI=","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=1777443339;\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=2VfZXoTHvjhG67THmg+181c4LzbjHd6mR6FEcY3MCcg=;\n b=BgEluo5xJLVP0s2GvOXDBb4LANQYU6r7oR9l2+J4lO+QTNc/L6Mu7rHB2bsweluH9tOmAn\n 0mElq2wqXp5ONt8wRhku+ftTpo3e8WBFO9Z+PpbZPoIC29NnNz2NZdYoo7DH0AQ53fGDLD\n dony6rkD6aDapO5JgegOOygpd1FagOc=","X-MC-Unique":"j5RB7i8zNbaPUaOJjEiDUg-1","X-Mimecast-MFC-AGG-ID":"j5RB7i8zNbaPUaOJjEiDUg_1777443335","Date":"Wed, 29 Apr 2026 08:15:31 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Richard Biener <rguenther@suse.de>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] bitintlower: Padding bit fixes, part 6 [PR123635]","Message-ID":"<afGiA9mbF4L3VzTH@tucnak>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"ZwCUplOI-KqwesOODcExYZJ9PODvSekJFdLEh1faZUY_1777443335","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\nI've missed torture/bitint-{93,94}.c FAILs on s390x-linux (i.e. big endian).\nFor __builtin_mul_overflow, the code to extend the partial most significant\nlimb is done before memmoving it down, so that limb actually isn't on big\nendian at offset 0 but is nelts - obj_nelts.  The following patch computes\nobj_nelts first, uses it on big-endian and so that the offset checking\nasserts don't trigger, on big-endian also uses NULL_TREE first argument to\nlimb_access.\n\nBootstrapped/regtested on x86_64-linux, i686-linux, powerpc64le-linux,\naarch64-linux and s390x-linux, ok for trunk and 16.2?\n\n2026-04-29  Jakub Jelinek  <jakub@redhat.com>\n\n\tPR middle-end/123635\n\t* gimple-lower-bitint.cc (bitint_large_huge::finish_arith_overflow):\n\tMove obj_nelts/atype computation before bitint_extended handling.  For\n\tbitint_big_endian in the bitint_extended handling use size_zero_node\n\tonly for limb_access_type calls, otherwise use\n\tsize_int (nelts - obj_nelts) and pass NULL_TREE as first argument to\n\tlimb_access calls.\n\n\n\tJakub","diff":"--- gcc/gimple-lower-bitint.cc.jj\t2026-04-24 14:36:20.686912090 +0200\n+++ gcc/gimple-lower-bitint.cc\t2026-04-28 16:58:30.724938682 +0200\n@@ -4478,6 +4478,13 @@ bitint_large_huge::finish_arith_overflow\n     {\n       unsigned HOST_WIDE_INT obj_nelts = 0;\n       tree atype = NULL_TREE;\n+      if (obj)\n+\t{\n+\t  obj_nelts = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (obj))) / limb_prec;\n+\t  if (orig_obj == NULL_TREE)\n+\t    obj_nelts >>= 1;\n+\t  atype = build_array_type_nelts (m_limb_type, obj_nelts);\n+\t}\n       if (bitint_extended && (var || obj))\n \t{\n \t  unsigned prec = TYPE_PRECISION (type);\n@@ -4492,9 +4499,13 @@ bitint_large_huge::finish_arith_overflow\n \t  if ((code == MULT_EXPR && (prec % limb_prec) != 0)\n \t      || (ext_ms_limb && !TYPE_UNSIGNED (type)))\n \t    {\n-\t      tree plm1idx = size_int (bitint_big_endian ? 0 : prec_limbs - 1);\n-\t      tree plm1type = limb_access_type (type, plm1idx);\n-\t      tree l = limb_access (type, var ? var : obj, plm1idx, true);\n+\t      tree plm1idx = size_int (bitint_big_endian\n+\t\t\t\t       ? nelts - obj_nelts : prec_limbs - 1);\n+\t      tree plm1type\n+\t\t= limb_access_type (type, bitint_big_endian\n+\t\t\t\t\t  ? size_zero_node : plm1idx);\n+\t      tree l = limb_access (bitint_big_endian ? NULL_TREE : type,\n+\t\t\t\t    var ? var : obj, plm1idx, true);\n \t      tree rhs = make_ssa_name (TREE_TYPE (l));\n \t      g = gimple_build_assign (rhs, l);\n \t      insert_before (g);\n@@ -4505,7 +4516,8 @@ bitint_large_huge::finish_arith_overflow\n \t\t  if (!useless_type_conversion_p (TREE_TYPE (l),\n \t\t\t\t\t\t  TREE_TYPE (rhs)))\n \t\t    rhs = add_cast (TREE_TYPE (l), rhs);\n-\t\t  l = limb_access (type, var ? var : obj, plm1idx, true);\n+\t\t  l = limb_access (bitint_big_endian ? NULL_TREE : type,\n+\t\t\t\t   var ? var : obj, plm1idx, true);\n \t\t  g = gimple_build_assign (l, rhs);\n \t\t  insert_before (g);\n \t\t}\n@@ -4537,13 +4549,6 @@ bitint_large_huge::finish_arith_overflow\n \t      insert_before (g);\n \t    }\n \t}\n-      if (obj)\n-\t{\n-\t  obj_nelts = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (obj))) / limb_prec;\n-\t  if (orig_obj == NULL_TREE)\n-\t    obj_nelts >>= 1;\n-\t  atype = build_array_type_nelts (m_limb_type, obj_nelts);\n-\t}\n       if (var && obj)\n \t{\n \t  tree v1, v2;\n","prefixes":[]}