Skip to content

Commit e9ed24b

Browse files
authored
vcacheoptimizer: Tweak condition to help MSVC generate branchless code (#639)
gcc/clang lower the condition to cmov sequence but MSVC uses branches here; it's important to use branchless lowering as these branches are difficult to predict. This change makes optimizeVertexCache ~7% faster on MSVC on large meshes.
1 parent abb12d3 commit e9ed24b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vcacheoptimizer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
260260
unsigned int index = cache[i];
261261

262262
cache_new[cache_write] = index;
263-
cache_write += (index != a && index != b && index != c);
263+
cache_write += (index != a) & (index != b) & (index != c);
264264
}
265265

266266
unsigned int* cache_temp = cache;

0 commit comments

Comments
 (0)