top | item 35765309 (no title) exebook | 2 years ago I guess while Python interprets this branchless code it still can do some branching? Or am I missing something here? discuss order hn newest juliusgeo|2 years ago There are some provisos to the “Branchless” tag that are covered in the article I drew inspiration from. One of which is that a “CMOVE” is not technically a branch :) yarg|2 years ago You have to do some really weird shit if you want generalised branchless ternary statements. begin += (arr[step+begin] < value)?step:0; Something like: int mask = ((arr[step + begin] - value) >> 31); //Depends on signed shift begin += (step & mask) | (0 & ~mask); (Obviously in this case, it's simplifiable.) load replies (2)
juliusgeo|2 years ago There are some provisos to the “Branchless” tag that are covered in the article I drew inspiration from. One of which is that a “CMOVE” is not technically a branch :) yarg|2 years ago You have to do some really weird shit if you want generalised branchless ternary statements. begin += (arr[step+begin] < value)?step:0; Something like: int mask = ((arr[step + begin] - value) >> 31); //Depends on signed shift begin += (step & mask) | (0 & ~mask); (Obviously in this case, it's simplifiable.) load replies (2)
yarg|2 years ago You have to do some really weird shit if you want generalised branchless ternary statements. begin += (arr[step+begin] < value)?step:0; Something like: int mask = ((arr[step + begin] - value) >> 31); //Depends on signed shift begin += (step & mask) | (0 & ~mask); (Obviously in this case, it's simplifiable.) load replies (2)
juliusgeo|2 years ago
yarg|2 years ago