From: drh <> Date: Wed, 3 Aug 2022 19:53:54 +0000 (+0000) Subject: Performance optimization to the math opcodes of the bytecode engine. X-Git-Tag: version-3.40.0~261 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3cf46ee508e97b46736a2607ded9c84c2c16229f;p=thirdparty%2Fsqlite.git Performance optimization to the math opcodes of the bytecode engine. FossilOrigin-Name: 597347d9c39f6ed068ac942a8c9853b1b745fce1eb5e9dd30f6c1cb312b36f53 --- diff --git a/manifest b/manifest index 7263c92943..75438ca23f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\sperformance\sincrease\son\sthe\sbinding\sinterfaces. -D 2022-08-03T19:37:25.175 +C Performance\soptimization\sto\sthe\smath\sopcodes\sof\sthe\sbytecode\sengine. +D 2022-08-03T19:53:54.082 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -642,7 +642,7 @@ F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 F src/util.c 602fe229f32a96ceccae4f40824129669582096f7c355f53dbac156c9fecef23 F src/vacuum.c bb346170b0b54c6683bba4a5983aea40485597fdf605c87ec8bc2e199fe88cd8 -F src/vdbe.c 1266f3a4744224253dd74f0080014be8056b062c6f2f6a81e229fa0d306d4102 +F src/vdbe.c 34f76cbbd886d90413b4503e6d46d7425152b88219bdd4e6bcaf81da75640d3e F src/vdbe.h 64619af62603dc3c4f5ff6ff6d2c8f389abd667a29ce6007ed44bd22b3211cd0 F src/vdbeInt.h 2cad0aeeb106371ed0e0946bab89f60627087068847afc2451c05056961c18da F src/vdbeapi.c 4181dffeef6ee181275cfecf27ad8577024c17ee9639531decdf4162b8c0326b @@ -1981,8 +1981,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c1ab0ea2959259cbd29f624bfd5e7366035f2dbcaab72c0bf55723c0919b7a79 -R 6d30ee627cafae056fe4256608756484 +P aab24c37fb444804fb91177b4b522909ef1bb85383444d97d82a758f919047d2 +R e2ed79990c9f576213c6203a5349f2b7 U drh -Z 20186bacd0ffc8dda8aa3c7b92c68f3f +Z ef554432af87d216083ec59e16ec0e61 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0fa5666afd..a35147d8e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aab24c37fb444804fb91177b4b522909ef1bb85383444d97d82a758f919047d2 \ No newline at end of file +597347d9c39f6ed068ac942a8c9853b1b745fce1eb5e9dd30f6c1cb312b36f53 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 5a6a8fbdc2..0b6fee3521 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1731,7 +1731,6 @@ case OP_Subtract: /* same as TK_MINUS, in1, in2, out3 */ case OP_Multiply: /* same as TK_STAR, in1, in2, out3 */ case OP_Divide: /* same as TK_SLASH, in1, in2, out3 */ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ - u16 flags; /* Combined MEM_* flags from both inputs */ u16 type1; /* Numeric type of left operand */ u16 type2; /* Numeric type of right operand */ i64 iA; /* Integer value of left operand */ @@ -1740,12 +1739,12 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ double rB; /* Real value of right operand */ pIn1 = &aMem[pOp->p1]; - type1 = numericType(pIn1); + type1 = pIn1->flags; pIn2 = &aMem[pOp->p2]; - type2 = numericType(pIn2); + type2 = pIn2->flags; pOut = &aMem[pOp->p3]; - flags = pIn1->flags | pIn2->flags; if( (type1 & type2 & MEM_Int)!=0 ){ +int_math: iA = pIn1->u.i; iB = pIn2->u.i; switch( pOp->opcode ){ @@ -1767,9 +1766,12 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ } pOut->u.i = iB; MemSetTypeFlag(pOut, MEM_Int); - }else if( (flags & MEM_Null)!=0 ){ + }else if( ((type1 | type2) & MEM_Null)!=0 ){ goto arithmetic_result_is_null; }else{ + type1 = numericType(pIn1); + type2 = numericType(pIn2); + if( (type1 & type2 & MEM_Int)!=0 ) goto int_math; fp_math: rA = sqlite3VdbeRealValue(pIn1); rB = sqlite3VdbeRealValue(pIn2);