llvmpipe: Factor out lp_build_select from lp_build_select_aos.
This commit is contained in:
parent
57907e7fd9
commit
af608e56ca
|
@ -131,6 +131,32 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
|
|||
}
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_select(struct lp_build_context *bld,
|
||||
LLVMValueRef mask,
|
||||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
|
||||
if(a == b)
|
||||
return a;
|
||||
|
||||
/* TODO: On SSE4 we could do this with a single instruction -- PBLENDVB */
|
||||
|
||||
a = LLVMBuildAnd(bld->builder, a, mask, "");
|
||||
|
||||
/* This often gets translated to PANDN, but sometimes the NOT is
|
||||
* pre-computed and stored in another constant. The best strategy depends
|
||||
* on available registers, so it is not a big deal -- hopefully LLVM does
|
||||
* the right decision attending the rest of the program.
|
||||
*/
|
||||
b = LLVMBuildAnd(bld->builder, b, LLVMBuildNot(bld->builder, mask, ""), "");
|
||||
|
||||
return LLVMBuildOr(bld->builder, a, b, "");
|
||||
}
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_select_aos(struct lp_build_context *bld,
|
||||
LLVMValueRef a,
|
||||
|
@ -188,19 +214,7 @@ lp_build_select_aos(struct lp_build_context *bld,
|
|||
#endif
|
||||
else {
|
||||
LLVMValueRef mask = lp_build_const_mask_aos(type, cond);
|
||||
|
||||
/* TODO: On SSE4 we could do this with a single instruction -- PBLENDVB */
|
||||
|
||||
a = LLVMBuildAnd(bld->builder, a, mask, "");
|
||||
|
||||
/* This often gets translated to PANDN, but sometimes the NOT is
|
||||
* pre-computed and stored in another constant. The best strategy depends
|
||||
* on available registers, so it is not a big deal -- hopefully LLVM does
|
||||
* the right decision attending the rest of the program.
|
||||
*/
|
||||
b = LLVMBuildAnd(bld->builder, b, LLVMBuildNot(bld->builder, mask, ""), "");
|
||||
|
||||
return LLVMBuildOr(bld->builder, a, b, "");
|
||||
return lp_build_select(bld, mask, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,12 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
|
|||
unsigned channel);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_select(struct lp_build_context *bld,
|
||||
LLVMValueRef mask,
|
||||
LLVMValueRef a,
|
||||
LLVMValueRef b);
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_select_aos(struct lp_build_context *bld,
|
||||
LLVMValueRef a,
|
||||
|
|
Loading…
Reference in New Issue