8000 jit: Stop emitting some unnecessary instructions · postgres/postgres@cfd7f36 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script type="application/json" data-target="react-app.embeddedData">{"payload":{"commit":{"oid":"cfd7f36c83cdcf6322c7ea0d1d9ef62bc2b00375","url":"/postgres/postgres/commit/cfd7f36c83cdcf6322c7ea0d1d9ef62bc2b00375","authoredDate":"2024-11-15T10:06:36.000+02:00","committedDate":"2024-11-15T10:06:36.000+02:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003ejit: Stop emitting some unnecessary instructions\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"In EEOP_BOOL_AND_STEP* and EEOP_BOOL_OR_STEP*, we emitted pointlesss\nstore instructions to store to resnull/resvalue values that were just\nloaded from the same fields in the previous instructions. They will\nsurely get optimized away by LLVM if any optimizations are enabled,\nbut it's better to not emit them in the first place. In\nEEOP_BOOL_NOT_STEP, similar story with resnull.\n\nIn EEOP_NULLIF, when it returns NULL, there was also a redundant store\nto resvalue just after storing a 0 to it. The value of resvalue\ndoesn't matter when resnull is set, so in fact even storing the 0 is\nunnecessary, but I kept that because we tend to do that for general\ntidiness.\n\nAuthor: Xing Guo \u0026lt;higuoxing@gmail.com\u0026gt;\nReviewed-by: Andreas Karlsson \u0026lt;andreas@proxel.se\u0026gt;\nDiscussion: \u003ca href=\"https://www.postgresql.org/message-id/CACpMh%2BC%3Dg13WdvzLRSponsVWGgxwDSMzQWM4Gz0heOyaA0-N6g@mail.gmail.com\" rel=\"nofollow\"\u003ehttps://www.postgresql.org/message-id/CACpMh%2BC%3Dg13WdvzLRSponsVWGgxwDSMzQWM4Gz0heOyaA0-N6g@mail.gmail.com\u003c/a\u003e","authors":[{"login":"hlinnaka","displayName":"Heikki Linnakangas","avatarUrl":"https://avatars.githubusercontent.com/u/191602?v=4","path":"/hlinnaka","isGitHub":false}],"committerAttribution":false,"committer":{"login":"hlinnaka","displayName":"Heikki Linnakangas","avatarUrl":"https://avatars.githubusercontent.com/u/191602?v=4","path":"/hlinnaka","isGitHub":false},"parents":["e468ec0fddcd93e282da6685b75d5687c2a87f2a"],"globalRelayId":"C_kwDOAA4m0toAKGNmZDdmMzZjODNjZGNmNjMyMmM3ZWEwZDFkOWVmNjJiYzJiMDAzNzU","sha1":"e468ec0fddcd93e282da6685b75d5687c2a87f2a","sha2":"cfd7f36c83cdcf6322c7ea0d1d9ef62bc2b00375"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":719,"text":"@@ -720,11 +720,6 @@ llvm_compile_expr(ExprState *state)","html":"@@ -720,11 +720,6 @@ llvm_compile_expr(ExprState *state)","displayNoNewLineWarning":false,"position":0,"left":719,"right":719},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":720,"text":" \t\t\t\t\tv_boolnull = l_load(b, TypeStorageBool, v_resnullp, \"\");","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003el_load\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eTypeStorageBool\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resnullp\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":1,"left":720,"right":720},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":721,"text":" \t\t\t\t\tv_boolvalue = l_load(b, TypeSizeT, v_resvaluep, \"\");","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003el_load\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eTypeSizeT\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":2,"left":721,"right":721},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":722,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":3,"left":722,"right":722},{"stylingDirective":null,"type":"DELETION","blobLineNumber":723,"text":"-\t\t\t\t\t/* set resnull to boolnull */","html":"-\t\t\t\t\t\u003cspan class=pl-c\u003e/* set resnull to boolnull */\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":723,"right":722},{"stylingDirective":null,"type":"DELETION","blobLineNumber":724,"text":"-\t\t\t\t\tLLVMBuildStore(b, v_boolnull, v_resnullp);","html":"-\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resnullp\u003c/span\u003e);","displayNoNewLineWarning":false,"position":5,"left":724,"right":722},{"stylingDirective":null,"type":"DELETION","blobLineNumber":725,"text":"-\t\t\t\t\t/* set revalue to boolvalue */","html":"-\t\t\t\t\t\u003cspan class=pl-c\u003e/* set revalue to boolvalue */\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":725,"right":722},{"stylingDirective":null,"type":"DELETION","blobLineNumber":726,"text":"-\t\t\t\t\tLLVMBuildStore(b, v_boolvalue, v_resvaluep);","html":"-\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e);","displayNoNewLineWarning":false,"position":7,"left":726,"right":722},{"stylingDirective":null,"type":"DELETION","blobLineNumber":727,"text":"-","html":"-","displayNoNewLineWarning":false,"position":8,"left":727,"right":722},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":723,"text":" \t\t\t\t\t/* check if current input is NULL */","html":" \t\t\t\t\t\u003cspan class=pl-c\u003e/* check if current input is NULL */\u003c/span\u003e","displayNoNewLineWarning":false,"position":9,"left":728,"right":723},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":724,"text":" \t\t\t\t\tLLVMBuildCondBr(b,","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildCondBr\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e,","displayNoNewLineWarning":false,"position":10,"left":729,"right":724},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":725,"text":" \t\t\t\t\t\t\t\t\tLLVMBuildICmp(b, LLVMIntEQ, v_boolnull,","html":" \t\t\t\t\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildICmp\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eLLVMIntEQ\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e,","displayNoNewLineWarning":false,"position":11,"left":730,"right":725},{"stylingDirective":null,"type":"HUNK","blobLineNumber":810,"text":"@@ -816,11 +811,6 @@ llvm_compile_expr(ExprState *state)","html":"@@ -816,11 +811,6 @@ llvm_compile_expr(ExprState *state)","displayNoNewLineWarning":false,"position":12,"left":815,"right":810},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":811,"text":" \t\t\t\t\tv_boolnull = l_load(b, TypeStorageBool, v_resnullp, \"\");","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003el_load\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eTypeStorageBool\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resnullp\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":13,"left":816,"right":811},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":812,"text":" \t\t\t\t\tv_boolvalue = l_load(b, TypeSizeT, v_resvaluep, \"\");","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003el_load\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eTypeSizeT\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":14,"left":817,"right":812},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":813,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":15,"left":818,"right":813},{"stylingDirective":null,"type":"DELETION","blobLineNumber":819,"text":"-\t\t\t\t\t/* set resnull to boolnull */","html":"-\t\t\t\t\t\u003cspan class=pl-c\u003e/* set resnull to boolnull */\u003c/span\u003e","displayNoNewLineWarning":false,"position":16,"left":819,"right":813},{"stylingDirective":null,"type":"DELETION","blobLineNumber":820,"text":"-\t\t\t\t\tLLVMBuildStore(b, v_boolnull, v_resnullp);","html":"-\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resnullp\u003c/span\u003e);","displayNoNewLineWarning":false,"position":17,"left":820,"right":813},{"stylingDirective":null,"type":"DELETION","blobLineNumber":821,"text":"-\t\t\t\t\t/* set revalue to boolvalue */","html":"-\t\t\t\t\t\u003cspan class=pl-c\u003e/* set revalue to boolvalue */\u003c/span\u003e","displayNoNewLineWarning":false,"position":18,"left":821,"right":813},{"stylingDirective":null,"type":"DELETION","blobLineNumber":822,"text":"-\t\t\t\t\tLLVMBuildStore(b, v_boolvalue, v_resvaluep);","html":"-\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e);","displayNoNewLineWarning":false,"position":19,"left":822,"right":813},{"stylingDirective":null,"type":"DELETION","blobLineNumber":823,"text":"-","html":"-","displayNoNewLineWarning":false,"position":20,"left":823,"right":813},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":814,"text":" \t\t\t\t\tLLVMBuildCondBr(b,","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildCondBr\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e,","displayNoNewLineWarning":false,"position":21,"left":824,"right":814},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":815,"text":" \t\t\t\t\t\t\t\t\tLLVMBuildICmp(b, LLVMIntEQ, v_boolnull,","html":" \t\t\t\t\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildICmp\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eLLVMIntEQ\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e,","displayNoNewLineWarning":false,"position":22,"left":825,"right":815},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":816,"text":" \t\t\t\t\t\t\t\t\t\t\t\t l_sbool_const(1), \"\"),","html":" \t\t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-en\u003el_sbool_const\u003c/span\u003e(\u003cspan class=pl-c1\u003e1\u003c/span\u003e), \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e),","displayNoNewLineWarning":false,"position":23,"left":826,"right":816},{"stylingDirective":null,"type":"HUNK","blobLineNumber":864,"text":"@@ -875,21 +865,22 @@ llvm_compile_expr(ExprState *state)","html":"@@ -875,21 +865,22 @@ llvm_compile_expr(ExprState *state)","displayNoNewLineWarning":false,"position":24,"left":874,"right":864},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":865,"text":" \t\t\tcase EEOP_BOOL_NOT_STEP:","html":" \t\t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eEEOP_BOOL_NOT_STEP\u003c/span\u003e:","displayNoNewLineWarning":false,"position":25,"left":875,"right":865},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":866,"text":" \t\t\t\t{","html":" \t\t\t\t{","displayNoNewLineWarning":false,"position":26,"left":876,"right":866},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":867,"text":" \t\t\t\t\tLLVMValueRef v_boolvalue;","html":" \t\t\t\t\t\u003cspan class=pl-smi\u003eLLVMValueRef\u003c/span\u003e \u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e;","displayNoNewLineWarning":false,"position":27,"left":877,"right":867},{"stylingDirective":null,"type":"DELETION","blobLineNumber":878,"text":"-\t\t\t\t\tLLVMValueRef v_boolnull;","html":"-\t\t\t\t\t\u003cspan class=pl-smi\u003eLLVMValueRef\u003c/span\u003e \u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e;","displayNoNewLineWarning":false,"position":28,"left":878,"right":867},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":868,"text":" \t\t\t\t\tLLVMValueRef v_negbool;","html":" \t\t\t\t\t\u003cspan class=pl-smi\u003eLLVMValueRef\u003c/span\u003e \u003cspan class=pl-s1\u003ev_negbool\u003c/span\u003e;","displayNoNewLineWarning":false,"position":29,"left":879,"right":868},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":869,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":30,"left":880,"right":869},{"stylingDirective":null,"type":"DELETION","blobLineNumber":881,"text":"-\t\t\t\t\tv_boolnull = l_load(b, TypeStorageBool, v_resnullp, \"\");","html":"-\t\t\t\t\t\u003cspan class=\"pl-s1 x x-first\"\u003ev_boolnull\u003c/span\u003e\u003cspan class=\"x\"\u003e \u003c/span\u003e\u003cspan class=\"pl-c1 x\"\u003e=\u003c/span\u003e\u003cspan class=\"x\"\u003e \u003c/span\u003e\u003cspan class=\"pl-en x\"\u003el_load\u003c/span\u003e\u003cspan class=\"x\"\u003e(\u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003eb\u003c/span\u003e\u003cspan class=\"x\"\u003e, \u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003eTypeStorageBool\u003c/span\u003e\u003cspan class=\"x\"\u003e, \u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003ev_resnullp\u003c/span\u003e\u003cspan class=\"x\"\u003e, \u003c/span\u003e\u003cspan class=\"pl-s x\"\u003e\"\"\u003c/span\u003e\u003cspan class=\"x x-last\"\u003e);\u003c/span\u003e","displayNoNewLineWarning":false,"position":31,"left":881,"right":869},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":870,"text":"+\t\t\t\t\t/* compute !boolvalue */","html":"+\t\t\t\t\t\u003cspan class=\"pl-c x x-first x-last\"\u003e/* compute !boolvalue */\u003c/span\u003e","displayNoNewLineWarning":false,"position":32,"left":881,"right":870},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":871,"text":" \t\t\t\t\tv_boolvalue = l_load(b, TypeSizeT, v_resvaluep, \"\");","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003el_load\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eTypeSizeT\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":33,"left":882,"right":871},{"stylingDirective":null,"type":"DELETION","blobLineNumber":883,"text":"-","html":"-","displayNoNewLineWarning":false,"position":34,"left":883,"right":871},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":872,"text":" \t\t\t\t\tv_negbool = LLVMBuildZExt(b,","html":" \t\t\t\t\t\u003cspan class=pl-s1\u003ev_negbool\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eLLVMBuildZExt\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e,","displayNoNewLineWarning":false,"position":35,"left":884,"right":872},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":873,"text":" \t\t\t\t\t\t\t\t\t\t\t LLVMBuildICmp(b, LLVMIntEQ,","html":" \t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-en\u003eLLVMBuildICmp\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eLLVMIntEQ\u003c/span\u003e,","displayNoNewLineWarning":false,"position":36,"left":885,"right":873},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":874,"text":" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\tv_boolvalue,","html":" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\u003cspan class=pl-s1\u003ev_boolvalue\u003c/span\u003e,","displayNoNewLineWarning":false,"position":37,"left":886,"right":874},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":875,"text":" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\tl_sizet_const(0),","html":" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\u003cspan class=pl-en\u003el_sizet_const\u003c/span\u003e(\u003cspan class=pl-c1\u003e0\u003c/span\u003e),","displayNoNewLineWarning":false,"position":38,"left":887,"right":875},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":876,"text":" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"\"),","html":" \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e),","displayNoNewLineWarning":false,"position":39,"left":888,"right":876},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":877,"text":" \t\t\t\t\t\t\t\t\t\t\t TypeSizeT, \"\");","html":" \t\t\t\t\t\t\t\t\t\t\t \u003cspan class=pl-s1\u003eTypeSizeT\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;\u0026quot;\u003c/span\u003e);","displayNoNewLineWarning":false,"position":40,"left":889,"right":877},{"stylingDirective":null,"type":"DELETION","blobLineNumber":890,"text":"-\t\t\t\t\t/* set resnull to boolnull */","html":"-\t\t\t\t\t\u003cspan class=pl-c\u003e/* set resnull to boolnull */\u003c/span\u003e","displayNoNewLineWarning":false,"position":41,"left":890,"right":877},{"stylingDirective":null,"type":"DELETION","blobLineNumber":891,"text":"-\t\t\t\t\tLLVMBuildStore(b, v_boolnull, v_resnullp);","html":"-\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_boolnull\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resnullp\u003c/span\u003e);","displayNoNewLineWarning":false,"position":42,"left":891,"right":877},{"stylingDirective":null,"type":"DELETION","blobLineNumber":892,"text":"-\t\t\t\t\t/* set revalue to !boolvalue */","html":"-\t\t\t\t\t\u003cspan class=pl-c\u003e/* set revalue to !boolvalue */\u003c/span\u003e","displayNoNewLineWarning":false,"position":43,"left":892,"right":877},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":878,"text":"+","html":"+","displayNoNewLineWarning":false,"position":44,"left":892,"right":878},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":879,"text":"+\t\t\t\t\t/*","html":"+\t\t\t\t\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":45,"left":892,"right":879},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":880,"text":"+\t\t\t\t\t * Store it back in resvalue. We can ignore resnull here;","html":"+\u003cspan class=pl-c\u003e\t\t\t\t\t * Store it back in resvalue. We can ignore resnull here;\u003c/span\u003e","displayNoNewLineWarning":false,"position":46,"left":892,"right":880},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":881,"text":"+\t\t\t\t\t * if it was true, it stays true, and the value we store","html":"+\u003cspan class=pl-c\u003e\t\t\t\t\t * if it was true, it stays true, and the value we store\u003c/span\u003e","displayNoNewLineWarning":false,"position":47,"left":892,"right":881},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":882,"text":"+\t\t\t\t\t * in resvalue doesn't matter.","html":"+\u003cspan class=pl-c\u003e\t\t\t\t\t * in resvalue doesn\u0026#39;t matter.\u003c/span\u003e","displayNoNewLineWarning":false,"position":48,"left":892,"right":882},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":883,"text":"+\t\t\t\t\t */","html":"+\u003cspan class=pl-c\u003e\t\t\t\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":49,"left":892,"right":883},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":884,"text":" \t\t\t\t\tLLVMBuildStore(b, v_negbool, v_resvaluep);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_negbool\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e);","displayNoNewLineWarning":false,"position":50,"left":893,"right":884},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":885,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":51,"left":894,"right":885},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":886,"text":" \t\t\t\t\tLLVMBuildBr(b, opblocks[opno + 1]);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildBr\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eopblocks\u003c/span\u003e[\u003cspan class=pl-s1\u003eopno\u003c/span\u003e \u003cspan class=pl-c1\u003e+\u003c/span\u003e \u003cspan class=pl-c1\u003e1\u003c/span\u003e]);","displayNoNewLineWarning":false,"position":52,"left":895,"right":886},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1605,"text":"@@ -1615,7 +1606,6 @@ llvm_compile_expr(ExprState *state)","html":"@@ -1615,7 +1606,6 @@ llvm_compile_expr(ExprState *state)","displayNoNewLineWarning":false,"position":53,"left":1614,"right":1605},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1606,"text":" \t\t\t\t\tLLVMPositionBuilderAtEnd(b, b_argsequal);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMPositionBuilderAtEnd\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eb_argsequal\u003c/span\u003e);","displayNoNewLineWarning":false,"position":54,"left":1615,"right":1606},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1607,"text":" \t\t\t\t\tLLVMBuildStore(b, l_sbool_const(1), v_resnullp);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-en\u003el_sbool_const\u003c/span\u003e(\u003cspan class=pl-c1\u003e1\u003c/span\u003e), \u003cspan class=pl-s1\u003ev_resnullp\u003c/span\u003e);","displayNoNewLineWarning":false,"position":55,"left":1616,"right":1607},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1608,"text":" \t\t\t\t\tLLVMBuildStore(b, l_sizet_const(0), v_resvaluep);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-en\u003el_sizet_const\u003c/span\u003e(\u003cspan class=pl-c1\u003e0\u003c/span\u003e), \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e);","displayNoNewLineWarning":false,"position":56,"left":1617,"right":1608},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1618,"text":"-\t\t\t\t\tLLVMBuildStore(b, v_retval, v_resvaluep);","html":"-\t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildStore\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_retval\u003c/span\u003e, \u003cspan class=pl-s1\u003ev_resvaluep\u003c/span\u003e);","displayNoNewLineWarning":false,"position":57,"left":1618,"right":1608},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1609,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":58,"left":1619,"right":1609},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1610,"text":" \t\t\t\t\tLLVMBuildBr(b, opblocks[opno + 1]);","html":" \t\t\t\t\t\u003cspan class=pl-en\u003eLLVMBuildBr\u003c/span\u003e(\u003cspan class=pl-s1\u003eb\u003c/span\u003e, \u003cspan class=pl-s1\u003eopblocks\u003c/span\u003e[\u003cspan class=pl-s1\u003eopno\u003c/span\u003e \u003cspan class=pl-c1\u003e+\u003c/span\u003e \u003cspan class=pl-c1\u003e1\u003c/span\u003e]);","displayNoNewLineWarning":false,"position":59,"left":1620,"right":1610},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1611,"text":" \t\t\t\t\tbreak;","html":" \t\t\t\t\t\u003cspan class=pl-k\u003ebreak\u003c/span\u003e;","displayNoNewLineWarning":false,"position":60,"left":1621,"right":1611}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":2993,"linesChanged":24,"newTreeEntry":{"lineCount":2993,"path":"src/backend/jit/llvm/llvmjit_expr.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/jit/llvm/llvmjit_expr.c","mode":100644},"linesAdded":7,"linesDeleted":17,"path":"src/backend/jit/llvm/llvmjit_expr.c","pathDigest":"70e00ef3c833c540131eed7ee267f05886f04b1585f0c2264a16303a761c116e","status":"MODIFIED","truncatedReason":null,"oldOid":"e468ec0fddcd93e282da6685b75d5687c2a87f2a","newOid":"cfd7f36c83cdcf6322c7ea0d1d9ef62bc2b00375","copilotChatReference":null,"deletedSha":"e468ec0fddcd93e282da6685b75d5687c2a87f2a","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/cfd7f36c83cdcf6322c7ea0d1d9ef62bc2b00375","fileTreeExpanded":true,"headerInfo":{"additions":7,"deletions":17,"filesChanged":1,"filesChangedString":"1"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":1,"truncated":false,"byteCount":2201,"lineShownCount":61},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"m0ROWm0UYR0cSN-tIKj0No1k8SiaCmZWFXIkPAgbrUhUbVODbtTyZ0G3lxJq-FiWHvW2uSjEc946T830qYapKg"},"/users/diffview?diff=unified":{"post":"fgylGN3sjdRnRfUMe4YZCQ9LbAZXiWezOXkNUP9AWH6xJbjB3iwerjq6vbMx1rWpnNorl-VHcjsWROSYXt1cHA"},"/notifications/thread":{"post":"tJLrmFHZEJqKDioOXxHhLvF9GAvm_ic6cxymfghROhsq0NCKLZ0KY5QaUHTQ7_DvSl_a22OQlDTT3ICxvNDbTQ"}}},"title":"jit: Stop emitting some unnecessary instructions · postgres/postgres@cfd7f36","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

Commit cfd7f36

Browse files
committed
jit: Stop emitting some unnecessary instructions
In EEOP_BOOL_AND_STEP* and EEOP_BOOL_OR_STEP*, we emitted pointlesss store instructions to store to resnull/resvalue values that were just loaded from the same fields in the previous instructions. They will surely get optimized away by LLVM if any optimizations are enabled, but it's better to not emit them in the first place. In EEOP_BOOL_NOT_STEP, similar story with resnull. In EEOP_NULLIF, when it returns NULL, there was also a redundant store to resvalue just after storing a 0 to it. The value of resvalue doesn't matter when resnull is set, so in fact even storing the 0 is unnecessary, but I kept that because we tend to do that for general tidiness. Author: Xing Guo <higuoxing@gmail.com> Reviewed-by: Andreas Karlsson <andreas@proxel.se> Discussion: https://www.postgresql.org/message-id/CACpMh%2BC%3Dg13WdvzLRSponsVWGgxwDSMzQWM4Gz0heOyaA0-N6g@mail.gmail.com
1 parent e468ec0 commit cfd7f36

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/backend/jit/llvm/llvmjit_expr.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,6 @@ llvm_compile_expr(ExprState *state)
720720
v_boolnull = l_load(b, TypeStorageBool, v_resnullp, "");
721721
v_boolvalue = l_load(b, TypeSizeT, v_resvaluep, "");
722722

723-
/* set resnull to boolnull */
724-
LLVMBuildStore(b, v_boolnull, v_resnullp);
725-
/* set revalue to boolvalue */
726-
LLVMBuildStore(b, v_boolvalue, v_resvaluep);
727-
728723
/* check if current input is NULL */
729724
LLVMBuildCondBr(b,
730725
LLVMBuildICmp(b, LLVMIntEQ, v_boolnull,
@@ -816,11 +811,6 @@ llvm_compile_expr(ExprState *state)
816811
v_boolnull = l_load(b, TypeStorageBool, v_resnullp, "");
817812
v_boolvalue = l_load(b, TypeSizeT, v_resvaluep, "");
818813

819-
/* set resnull to boolnull */
820-
LLVMBuildStore(b, v_boolnull, v_resnullp);
821-
/* set revalue to boolvalue */
822-
LLVMBuildStore(b, v_boolvalue, v_resvaluep);
823-
824814
LLVMBuildCondBr(b,
825815
LLVMBuildICmp(b, LLVMIntEQ, v_boolnull,
826816
l_sbool_const(1), ""),
@@ -875,21 +865,22 @@ llvm_compile_expr(ExprState *state)
875865
case EEOP_BOOL_NOT_STEP:
876866
{
877867
LLVMValueRef v_boolvalue;
878-
LLVMValueRef v_boolnull;
879868
LLVMValueRef v_negbool;
880869

881-
v_boolnull = l_load(b, TypeStorageBool, v_resnullp, "");
870+
/* compute !boolvalue */
882871
v_boolvalue = l_load(b, TypeSizeT, v_resvaluep, "");
883-
884872
v_negbool = LLVMBuildZExt(b,
885873
LLVMBuildICmp(b, LLVMIntEQ,
886874
v_boolvalue,
887875
l_sizet_const(0),
888876
""),
889877
TypeSizeT, "");
890-
/* set resnull to boolnull */
891-
LLVMBuildStore(b, v_boolnull, v_resnullp);
892-
/* set revalue to !boolvalue */
878+
879+
/*
880+
* Store it back in resvalue. We can ignore resnull here;
881+
* if it was true, it stays true, and the value we store
882+
* in resvalue doesn't matter.
883+
*/
893884
LLVMBuildStore(b, v_negbool, v_resvaluep);
894885

895886
LLVMBuildBr(b, opblocks[opno + 1]);
@@ -1615,7 +1606,6 @@ llvm_compile_expr(ExprState *state)
16151606
LLVMPositionBuilderAtEnd(b, b_argsequal);
16161607
LLVMBuildStore(b, l_sbool_const(1), v_resnullp);
16171608
LLVMBuildStore(b, l_sizet_const(0), v_resvaluep);
1618-
LLVMBuildStore(b, v_retval, v_resvaluep);
16191609

16201610
LLVMBuildBr(b, opblocks[opno + 1]);
16211611
break;

0 commit comments

Comments
 (0)
0