diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-03-11 15:36:51 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-03-11 15:42:41 +0000 |
commit | e24e5324ed1adce8da8ff268f7047ad8172bb248 (patch) | |
tree | a674998f05fa3005a60bce58c1fd0818798a7c1c | |
parent | 99f11f653012e8e18502cb0f5cce3cd1e0643c23 (diff) |
gallivm: Use bitmasks for scalar masks.
We could use single 1 bit conditions for scalar masks, but a lot of code
expects masks. The compiler easily optimzes away masks
extensions/truncations so consistency is preferable.
We can revisit this when LLVM backends have more support for vector
conditions.
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_logic.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index fa65895367..b7eb2c3d4e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -259,11 +259,13 @@ lp_build_compare(LLVMBuilderRef builder, cond = LLVMBuildFCmp(builder, op, a, b, ""); res = LLVMBuildSExt(builder, cond, int_vec_type, ""); #else - res = LLVMGetUndef(int_vec_type); if (type.length == 1) { - res = LLVMBuildFCmp(builder, op, a, b, ""); + cond = LLVMBuildFCmp(builder, op, a, b, ""); + res = LLVMBuildSExt(builder, cond, int_vec_type, ""); } else { + res = LLVMGetUndef(int_vec_type); + debug_printf("%s: warning: using slow element-wise float" " vector comparison\n", __FUNCTION__); for (i = 0; i < type.length; ++i) { @@ -311,11 +313,13 @@ lp_build_compare(LLVMBuilderRef builder, cond = LLVMBuildICmp(builder, op, a, b, ""); res = LLVMBuildSExt(builder, cond, int_vec_type, ""); #else - res = LLVMGetUndef(int_vec_type); if (type.length == 1) { - res = LLVMBuildICmp(builder, op, a, b, ""); + cond = LLVMBuildICmp(builder, op, a, b, ""); + res = LLVMBuildSExt(builder, cond, int_vec_type, ""); } else { + res = LLVMGetUndef(int_vec_type); + debug_printf("%s: warning: using slow element-wise int" " vector comparison\n", __FUNCTION__); @@ -357,6 +361,8 @@ lp_build_cmp(struct lp_build_context *bld, /** * Return mask ? a : b; + * + * mask is a bitwise mask, composed of 0 or ~0 for each element. */ LLVMValueRef lp_build_select(struct lp_build_context *bld, @@ -371,6 +377,7 @@ lp_build_select(struct lp_build_context *bld, return a; if (type.length == 1) { + mask = LLVMBuildTrunc(bld->builder, mask, LLVMInt1Type(), ""); res = LLVMBuildSelect(bld->builder, mask, a, b, ""); } else { |