Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxfL4-0005hI-U1 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Sep 2017 20:23:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dxfL4-00060m-Gk for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Sep 2017 20:23:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dxfJV-0002F9-L2 for pgsql-hackers@postgreSQL.org; Thu, 28 Sep 2017 20:21:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dxfJS-0002RA-O3 for pgsql-hackers@postgreSQL.org; Thu, 28 Sep 2017 20:21:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v8SKLYxP002509; Thu, 28 Sep 2017 16:21:34 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@postgreSQL.org Subject: Minor codegen silliness in ExecInterpExpr() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2507.1506630094.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 28 Sep 2017 16:21:34 -0400 Message-ID: <2508.1506630094@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I noticed the following while poking around with perf: | fcinfo->isnull =3D false; |b5b: movb $0x0,0x1c(%rdx) | *op->resvalue =3D op->d.func.fn_addr(f= cinfo); 0.02 | mov 0x8(%rbx),%rcx 1.19 | mov %rdx,%rdi 0.93 | mov %rdx,(%rsp) | mov %rcx,0x8(%rsp) 0.01 | callq *0x28(%rbx) 2.17 | mov 0x8(%rsp),%rcx | mov %rax,(%rcx) | *op->resnull =3D fcinfo->isnull; 1.18 | mov (%rsp),%rdx 4.32 | mov 0x10(%rbx),%rax 0.06 | movzbl 0x1c(%rdx),%edx 9.14 | mov %dl,(%rax) It looks to me like gcc believes it is required to evaluate "op->resvalue" before invoking the called function, just in case the function somehow has access to *op and modifies that. We could save a pointless register spill and reload if there were a temporary variable in there, ie EEO_CASE(EEOP_FUNCEXPR) { FunctionCallInfo fcinfo =3D op->d.func.fcinfo_data; + Datum fvalue; =09 fcinfo->isnull =3D false; - *op->resvalue =3D op->d.func.fn_addr(fcinfo); + fvalue =3D op->d.func.fn_addr(fcinfo); + *op->resvalue =3D fvalue; *op->resnull =3D fcinfo->isnull; EEO_NEXT(); } and likewise in the other FUNCEXPR cases. This is on a rather old gcc, haven't checked on bleeding-edge versions. regards, tom lane --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers