Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdBtj-00F7Bk-0j for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jan 2026 18:35:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdBth-009uLM-34 for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jan 2026 18:35:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdBth-009uLE-1u for pgsql-hackers@lists.postgresql.org; Tue, 06 Jan 2026 18:35:14 +0000 Received: from mail-dy1-x132f.google.com ([2607:f8b0:4864:20::132f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdBtf-004wdC-1R for pgsql-hackers@lists.postgresql.org; Tue, 06 Jan 2026 18:35:14 +0000 Received: by mail-dy1-x132f.google.com with SMTP id 5a478bee46e88-2abe15d8a4bso998076eec.0 for ; Tue, 06 Jan 2026 10:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767724510; x=1768329310; darn=lists.postgresql.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HH5wXBqWQYZj6WKcdhA3iZShKGmmbsey//PDe+/k5eg=; b=geoUHOulLkMTcDTeOxREBu3Xc/M7VFmCMozu/Ng3pFfkDe+6BHfs01CFAxrlXAy4Uo +DeFv3B7fdVdxLZvcFHTA7xuLeTBzUVj41atuyNQ2YlSQQgmsz+nHW8UJZZ4XI3DKf+v uxl43QH4BYD+gM6qwk/6sFnzZmJd8nl494yuNAAWgI+GjX8rl7nLmOFw4h68RGu3S3My +fQd4JuM9fvUjTS8NFm4PdFdc5A6Gsf5mAbfpqO/KwpVLGYaSjv4/EXqVDy2ZtprM+a5 pH0ozGbwAAnZs5ORYzWQ6lW3+VAbn5Q3BwLpRjyUlQ5Y6sjksU6SY5401MqXAUmENuFW 642Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767724510; x=1768329310; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HH5wXBqWQYZj6WKcdhA3iZShKGmmbsey//PDe+/k5eg=; b=GB/mOXEpJ1MH42JB7aeqwOnRQe3b5+hfY+hGqiaupNfK6nlNuF3LFEHByQ9EVYeVdk 07WTjks4KB+Ap/L7U09gSm8Dgw4URVkIFHYZ0ryu8S7KhhqEin6yL1oK6Xbi7HhqfSSR 5P1FOV3BSlkB0q9wDsXrq89ZZ21V1Xf1XExeUaM2pIPjrulMs2JVgatdW3F03N+o2S9q WkvkFaSk1KjYN4ghc9QYfoiFNqJWXwaSYj2DbymN8+9IWU4vdGHlCn4CbYm43JmmumEs bVNfd110tRS+q4Sthhw5qvIUB7gG/Cwoeai0/9DZObnbsdlc8bKmardyEeKCXVbfvYOG zC4g== X-Gm-Message-State: AOJu0YzZExDl7lPIJOwq09sMpSF3Q537hi9JsQQ39TdOMV5h7x2mNQwy JNs2UvqYIXYxRjMgwE7CmN/VzjBjyDAmh2j+GDCBQHuTdxNsE6ETqzlm X-Gm-Gg: AY/fxX5SRA09pLVcoek7MnhenCwFgZalIj3mpdXebp8zKUqpGroonqh4DhbxPQs0BUB KSjL7/7rTp68+RIyMsbRfS0yiwwYpCxq5suluplzDfiCsfpxLEaapsk/xcJnMMfwKiPAuZx/yqH 0sc6/BZ3QkQQy3APBvP4Rh7TAEi9SicvNQrbWAd/E1UrC2US7Jb9zKqsDo2XgUxkxTogtI/ZQuR NY8o6KU68OP5b0wzfkvvPGXi9MzH6SrQcxMUr9RslL1yUhD+gtqWUflc4yd7e5jsUUgJWcBUn26 WFvGAm4wwfVEO1mJJYgFmf4u91itASaUBFd7PJ7feH3ZbHdk23i8lKxSPno6FmflblNwjSrwDSE qtMUJaDaERHw6Bu5kKJSx7GsqCXxe3njFkY0zTrMe3LvXYywAV33e12EOLTupl0Ibpr+3BVV0oA /1rueZnq5n5+/LW+ok2+moyiZebvvnng3DCw== X-Google-Smtp-Source: AGHT+IF7dWBQG1IecIoxZ5rnqSbc0xFNBhXI9LxcJULg90tsaFPXLNqZB44nxXhdbFKAsSyJ+Nwf5g== X-Received: by 2002:a05:7300:3247:b0:2b0:5012:734a with SMTP id 5a478bee46e88-2b16f924ac7mr2600501eec.34.1767724509187; Tue, 06 Jan 2026 10:35:09 -0800 (PST) Received: from localhost ([2804:14d:328a:a59c:6df2:dbcc:d2f7:5e32]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b1707da231sm4859806eec.34.2026.01.06.10.35.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jan 2026 10:35:08 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 06 Jan 2026 15:35:06 -0300 Message-Id: Cc: "PostgreSQL Hackers" Subject: Re: LLVM 22 From: "Matheus Alcantara" To: "Thomas Munro" , "Matheus Alcantara" X-Mailer: aerc 0.21.0 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon Jan 5, 2026 at 8:50 PM -03, Thomas Munro wrote: >> > Here's a potential minimal fix. I haven't yet proven that the >> > optimisation is still working as expected. Probably need to compile >> > an expression that calls an inlined function and then a non-inlined >> > function with jit_dump_bitcode=3Dtrue, then find the right XXX.bc file >> > under pgdata, llvm-dis XXX.bc, llc XXX.ll, then visually inspect XXX.s >> > with enough caffeine to confirm that it's not spilling something (ie >> > store instructions) where previously it didn't, but I wanted to post >> > what I had so far to see if anyone has a better idea or an easy way to >> > test it... >> > >> I'm not super familiar with reading assembly code but I tried my best to >> inspect the LLVM 22 and LLVM 21 outputs and if I understood correctly I >> think that 0002 is working as expected. > > Cool. And as another sanity test, if you comment out the new poison > code so that we don't try to prevent unwanted spills/stores, can you > see any? > Yes, I've commented the poison code block introduced on 0002 and the generated assembly code seems more bloated, for example: LLVM 22 with 0002 and the poison code block commented: LBB2_8: mov x25, #15624 ; =3D0x3d08 movk x25, #7427, lsl #16 movk x25, #1, lsl #32 mov x20, #13805 ; =3D0x35ed movk x20, #7427, lsl #16 movk x20, #1, lsl #32 ldr x8, [x23] ldrb w9, [x24] stur x8, [x25, #-248] sturb w9, [x25, #-240] mov w26, #1 ; =3D0x1 strb w26, [x20, #1419] ldurb w8, [x25, #-240] cmp w8, #1 b.eq LBB2_11 LLVM 22 with 0002: LBB2_8: mov x20, #40824 ; =3D0x9f78 movk x20, #19456, lsl #16 movk x20, #1, lsl #32 ldr x8, [x23] ldrb w9, [x24] str x8, [x20, #152] strb w9, [x20, #160] mov w26, #1 ; =3D0x1 strb w26, [x20] cmp w9, #1 b.eq LBB2_11 IIUC with the commented code the LLVM compiler added an extra load ldurb followed by cmp w8, #1. With the patch it performs a comparison cmp w9, #1 directly using a register it already has. -- Matheus Alcantara EDB: https://www.enterprisedb.com