Module: Mesa
Branch: master
Commit: d42229707ad4be9be5a8e122354be7102d6ec348
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d42229707ad4be9be5a8e122354be7102d6ec348

Author: Jose Fonseca <jfons...@vmware.com>
Date:   Wed Mar 10 17:22:30 2010 -0500

gallivm: simplify conditional branching

Instead of testing each component individually, we can test the entire
vector at once.

---

 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   29 ++++++----------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index aa57289..b3a0fe7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -276,27 +276,14 @@ static void lp_exec_continue(struct lp_exec_mask *mask)
 static void lp_exec_endloop(struct lp_exec_mask *mask)
 {
    LLVMBasicBlockRef endloop;
-   LLVMValueRef i1cond;
-
-   { /* convert our soa vector into i1 */
-      int i;
-      LLVMValueRef packed = 0;
-      for (i = 0; i < mask->bld->type.length; ++i) {
-         LLVMValueRef component = LLVMBuildExtractElement(
-            mask->bld->builder,
-            mask->break_mask,
-            LLVMConstInt(LLVMInt32Type(), i, 0), "");
-         if (packed)
-            packed = LLVMBuildOr(mask->bld->builder,
-                                 packed, component, "");
-         else
-            packed = component;
-      }
-      i1cond = LLVMBuildICmp(mask->bld->builder, LLVMIntNE,
-                             packed,
-                             LLVMConstNull(LLVMTypeOf(packed)),
-                             "");
-   }
+   LLVMTypeRef reg_type = LLVMIntType(mask->bld->type.width*
+                                      mask->bld->type.length);
+   /* i1cond = (mask == 0) */
+   LLVMValueRef i1cond = LLVMBuildICmp(
+      mask->bld->builder,
+      LLVMIntNE,
+      LLVMBuildBitCast(mask->bld->builder, mask->break_mask, reg_type, ""),
+      LLVMConstNull(reg_type), "");
 
    endloop = lp_build_insert_new_block(mask->bld->builder, "endloop");
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to