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 1vj2QB-004U1g-1N for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 21:40:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vj2QA-00Erap-0F for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 21:40:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vj2Q9-00Erah-2U for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 21:40:54 +0000 Received: from mail-dy1-x1342.google.com ([2607:f8b0:4864:20::1342]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vj2Q7-001plk-1t for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 21:40:53 +0000 Received: by mail-dy1-x1342.google.com with SMTP id 5a478bee46e88-2b6fd5bec41so3149121eec.1 for ; Thu, 22 Jan 2026 13:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769118050; x=1769722850; 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=S3pu20lMfnhMF1lKOAMQV2ajc6PcAaKZIQxpsiUCfOs=; b=RE2wK2ys9hYHWxHUT5Y/lvMeEDkpU/OOjfnJnG6RffzJSfbIO8C7ukgnxBThEGzPnt xXxD8w+weqRhkyBj08Aq6jm6nezRqfTX03WE9oep/5Gm+rqFgzkYFx2Z3JremRp4/Wcd 2KempmR2V0b+SDUnYC+wUoPy+8/RYg8WA9610zvIisnQ6aivnOEKmgNjU77ymaboqSjE 6ruuUSBUCXDSpTLH28OhJ2aTMvp4LqscqpidKREycCy7NG+zivkTsfyKCGZJOrBMVxOC p3hVw/tAPRn0bH//X9NxNjDYYc1i61erkoZQzPZl7CS5t1ugqUQBjWt9SCVoJTuPCchj z1jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769118050; x=1769722850; 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=S3pu20lMfnhMF1lKOAMQV2ajc6PcAaKZIQxpsiUCfOs=; b=JZ0BQxQlR47n25y7W42Tr9ze7chrLYPBQmiT63c6xLKcebZQdvXx9cfGUnJ9+LgwjT 4UJZNWKIlOVI6QZiSMY/fUcgv/hp0/hWatL8JaCgJT5CPuC1ncNJNSFo9qqZ15ojxVud 931+A5Y88/if0CWnnMS4ECf03acPRPRZuL8SNUeke8lebX1IDy0ePR5hl9kKPoB3XgZ/ Ab75gc0fmkAT3CcL2fgR+Ej08lQw/JsIRMi6ERUC7B8ncthRbvk0gSHSLoDjyjzRSaC6 vZDx97l9fJnpEXs2JxwJjFrjnzZkRPHCkMSJBSwV3GBAIr3QdYlhY+mzKCXWhXY9PswA lJQQ== X-Gm-Message-State: AOJu0Ywxx01hOFq8l+KTHzeqdvNZaGWUeaP1S+jRVOCIfYFnYGpL2Dqa g20IxR9S7QGECKIu/oBSrqWg6WK8oR4AVVsZfRrtGh18GHq7fXcjvEgKlSsFQ9QG X-Gm-Gg: AZuq6aLmd4s6PewxWSR8IOhkoVjoSR4ND6+Kbhxqi9Kvpbc4zwrp9dhk4DWQB4yGBEv HRIiDXRlRFpAY4icMBbX4Nqy8ByYqh7x6Ip+0kRYQBvbRhcWCsHFIQsnOWAQDcoU2B+J1HNQBQM wk6zluZo0EU6h1ZbZSu5jEapT9AmKvJLyMoZ/UDncFHXk5puDJGksz08wabopz2tMnrl51EOGbN u7nOkQ8LWQ7P2aSIZAat86+kH03zNKSzLMRq4HleVik2ZcGdCa1/5Lk1dMYfwcZEu/pWRfCTW7/ 29NJ5kmDkolLZI5I/w1Tc4gKUCPYJIycsbDfUKOfbUbrhWAdtQlKE5LAR1BkAww4+dD9zEoXVXw Zqla0srZtF5NjyeniWO6H0tFuQ/O4Ubv4Me+trVxJYyWcsj5hEf2+JRfd85qf2KJTBjJ4JsmbIj 7H47k502SqCho3rgMuiSlDqE0ts1opEApc X-Received: by 2002:a05:7300:7250:b0:2b7:2664:aeae with SMTP id 5a478bee46e88-2b739bb1768mr375672eec.37.1769118049901; Thu, 22 Jan 2026 13:40:49 -0800 (PST) Received: from localhost ([2804:14d:328a:a59c:a9e2:7e1:e741:3ee8]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b73a6f5d2asm770517eec.14.2026.01.22.13.40.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jan 2026 13:40:49 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 22 Jan 2026 18:40:46 -0300 Message-Id: Cc: "pgsql-hackers@lists.postgresql.org" Subject: Re: [PATCH] llvmjit: always add the simplifycfg pass From: "Matheus Alcantara" To: "Pierre Ducroquet" 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 Thu Jan 22, 2026 at 5:27 PM -03, Pierre Ducroquet wrote: >> The patch needs a rebase due to e5d99b4d9ef. >>=20 >> You've added the "simplifycfg" only when the "jit_optimize_above_cost" >> is not triggered which will use the default and mem2reg passes, the >>=20 >> default pass already include "simplifycfg"? >>=20 >>=20 >> With e5d99b4d9ef being committed, should we add "simplifycfg" when >> PGJIT_INLINE bit is set since it also use the default and mem2reg >>=20 >> passes? > > Hi > > Thank you, here is a rebased version of the patch. > To answer your questions: > - O3 already includes simplifycfg, so no need to modify O3 > - any code generated by our llvmjit provider, esp. tuple deforming, is he= avily dependent on simplifycfg, so when O0 is the basis we should always ad= d this pass Thanks for confirming. I did some benchmarks on some TPCH queries (1 and 4) and I got these results. Note that for these tests I set jit_optimize_above_cost=3D1000000 so that it force to use the default pass with simplifycfg. Master Q1: Timing: Generation 1.553 ms (Deform 0.573 ms), Inlining 0.052 ms, Optim= ization 95.571 ms, Emission 58.941 ms, Total 156.116 ms Execution Time: 38221.318 ms Patch Q1: Timing: Generation 1.477 ms (Deform 0.534 ms), Inlining 0.040 ms, Optim= ization 95.364 ms, Emission 58.046 ms, Total 154.927 ms Execution Time: 38257.797 ms Master Q4: Timing: Generation 0.836 ms (Deform 0.309 ms), Inlining 0.086 ms, Optim= ization 5.098 ms, Emission 6.963 ms, Total 12.983 ms Execution Time: 19512.134 ms Patch Q4: Timing: Generation 0.802 ms (Deform 0.294 ms), Inlining 0.090 ms, Optim= ization 5.234 ms, Emission 6.521 ms, Total 12.648 ms Execution Time: 16051.483 ms For Q4 I see a small increase on Optimization phase but we have a good performance improvement on execution time. For Q1 the results are almost the same. I did not find any major regression using simplifycfg pass and I think that it make sense to enable since it generate better IR code for LLVM to compile without too much costs. +1 for this patch. Perhaps we could merge the comments on if/else block to include the simplifycfg, what do you think? + /* + * Determine the LLVM pass pipeline to use. For OPT3 we use the sta= ndard + * suite. For lower optimization levels, we explicitly include mem2= reg to + * promote stack variables, simplifycfg to clean up the control flo= w , and + * optionally the inliner if the flag is set. Note that default= already + * includes the always-inline pass. + */ if (context->base.flags & PGJIT_OPT3) passes =3D "default"; else if (context->base.flags & PGJIT_INLINE) - /* if doing inlining, but no expensive optimization, add in= line pass */ passes =3D "default,mem2reg,simplifycfg,inline"; else - /* default includes always-inline pass */ passes =3D "default,mem2reg,simplifycfg"; -- Matheus Alcantara EDB: https://www.enterprisedb.com