diff options
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/condmove.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/codegen/condmove.go b/test/codegen/condmove.go index 97be0ced75..6d3a46b03c 100644 --- a/test/codegen/condmove.go +++ b/test/codegen/condmove.go @@ -507,3 +507,23 @@ func cmovmathhalveu(a uint, b bool) uint { // wasm:"I64ShrU", -"Select" return a } + +func branchlessBoolToUint8(b bool) (r uint8) { + if b { + r = 1 + } + return +} + +func cmovFromMulFromFlags64(x uint64, b bool) uint64 { + // amd64:-"MOVB.ZX" + r := uint64(branchlessBoolToUint8(b)) + // amd64:"CMOV",-"MOVB.ZX",-"MUL" + return x * r +} +func cmovFromMulFromFlags64sext(x int64, b bool) int64 { + // amd64:-"MOVB.ZX" + r := int64(int8(branchlessBoolToUint8(b))) + // amd64:"CMOV",-"MOVB.ZX",-"MUL" + return x * r +} |
