Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 94eeb9a

Browse files
committedFeb 13, 2025·
DBResidueMask() cleanup
Reorder things in this function. Adding 'const' in key places to provide the compiler the extra hint for the purpose of this computation we don't change the value and the value never changes externally even across function calls. I'm sure the compiler (due to macro implementation of TTMaskXxxxx() calls and visibility of data being changes) will optimise the function in exactly the way of the reorder. This also should have the side-effect of making clearer more auto vectorization possibilities to the compiler or potentially replacing the loop with (tail-call or inline) to : simd_TTMaskSetMask_residues(lmask, rmask, TT_TECHDEPBASE, DBNumUserLayers); Which would be a hand optimized form, that probably has an 'l_residues' layout that favours SIMD use (2nd order copy from source of truth just in a different data layout, such as contiguous array of TileTypeBitMask indexed from 0, with the TileType as the index).
1 parent 9a4bf4e commit 94eeb9a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
 

‎database/DBtcontact.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -953,24 +953,22 @@ DBFullResidueMask(type, rmask)
953953
TileType type;
954954
TileTypeBitMask *rmask;
955955
{
956-
TileType t;
957-
TileTypeBitMask *lmask;
958-
LayerInfo *li, *lr;
959-
960-
li = &dbLayerInfo[type];
961-
lmask = &li->l_residues;
962-
TTMaskZero(rmask);
956+
LayerInfo *li = &dbLayerInfo[type];
957+
const TileTypeBitMask *lmask = &li->l_residues;
963958

964959
if (type < DBNumUserLayers)
965960
{
966-
TTMaskSetMask(rmask, &li->l_residues);
961+
TTMaskSetMask(rmask, lmask);
967962
}
968963
else
969964
{
970-
for (t = TT_TECHDEPBASE; t < DBNumUserLayers; t++)
965+
TileType t;
966+
const int tt_last = DBNumUserLayers;
967+
TTMaskZero(rmask);
968+
for (t = TT_TECHDEPBASE; t < tt_last; t++)
971969
if (TTMaskHasType(lmask, t))
972970
{
973-
lr = &dbLayerInfo[t];
971+
LayerInfo *lr = &dbLayerInfo[t];
974972
TTMaskSetMask(rmask, &lr->l_residues);
975973
}
976974
}

0 commit comments

Comments
 (0)
Please sign in to comment.