Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfd7f36

Browse files
committed
jit: Stop emitting some unnecessary instructions
In EEOP_BOOL_AND_STEP* and EEOP_BOOL_OR_STEP*, we emitted pointlesssstore instructions to store to resnull/resvalue values that were justloaded from the same fields in the previous instructions. They willsurely get optimized away by LLVM if any optimizations are enabled,but it's better to not emit them in the first place. InEEOP_BOOL_NOT_STEP, similar story with resnull.In EEOP_NULLIF, when it returns NULL, there was also a redundant storeto resvalue just after storing a 0 to it. The value of resvaluedoesn't matter when resnull is set, so in fact even storing the 0 isunnecessary, but I kept that because we tend to do that for generaltidiness.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 parente468ec0 commitcfd7f36

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
caseEEOP_BOOL_NOT_STEP:
876866
{
877867
LLVMValueRefv_boolvalue;
878-
LLVMValueRefv_boolnull;
879868
LLVMValueRefv_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)

[8]ページ先頭

©2009-2025 Movatter.jp