gallivm: alloca() was called too often for temporary arrays
authorBrian Paul <brianp@vmware.com>
Fri, 5 Nov 2010 14:49:53 +0000 (08:49 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 5 Nov 2010 14:49:57 +0000 (08:49 -0600)
Need to increment the array index to point to the last value.
Before, we were calling lp_build_array_alloca() over and over for
no reason.

src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c

index a74cefd41e18a11016e1de9a192f8c6600f60415..897b09ff22b94c265ba2abc9e92ad1a9f13a1639 100644 (file)
@@ -1189,10 +1189,12 @@ emit_declaration(
       case TGSI_FILE_TEMPORARY:
          assert(idx < LP_MAX_TGSI_TEMPS);
          if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
+            /* ignore 'first' - we want to index into a 0-based array */
             LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(),
                                                    last*4 + 4, 0);
             bld->temps_array = lp_build_array_alloca(bld->base.builder,
                                                      vec_type, array_size, "temparray");
+            idx = last;
          } else {
             for (i = 0; i < NUM_CHANNELS; i++)
                bld->temps[idx][i] = lp_build_alloca(bld->base.builder,