diff options
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/condmove.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/codegen/condmove.go b/test/codegen/condmove.go index 54e5f361fe..bd2d1540b4 100644 --- a/test/codegen/condmove.go +++ b/test/codegen/condmove.go @@ -6,6 +6,8 @@ package codegen +import "crypto/subtle" + func cmovint(c int) int { x := c + 4 if x < 0 { @@ -527,3 +529,11 @@ func cmovFromMulFromFlags64sext(x int64, b bool) int64 { // amd64:"CMOV",-"MOVB.ZX",-"MUL" return x * r } + +func constantTimeSelect(v, x, y int) int { + // amd64:"CMOVQ" + // arm64:"CSEL" + // riscv64/rva20u64,riscv64/rva22u64:"SNEZ" "NEG" "AND" "OR" + // riscv64/rva23u64:"NEG" "CZERONEZ" "CZEROEQZ" "OR" -"SNEZ" -"AND" + return subtle.ConstantTimeSelect(v, x, y) +} |
