Merge pull request #3011 from cfallin/bint-x64

Fix `bint` on x64, and make `bextend` consistent with bool representation.
This commit is contained in:
Chris Fallin
2021-06-22 11:26:20 -07:00
committed by GitHub
6 changed files with 105 additions and 17 deletions

View File

@@ -0,0 +1,16 @@
test compile
target x86_64 machinst
function %f0(b8) -> b64 {
block0(v0: b8):
v1 = bextend.b64 v0
return v1
}
; check: pushq %rbp
; nextln: movq %rsp, %rbp
; nextln: movsbq %dil, %rsi
; nextln: movq %rsi, %rax
; nextln: movq %rbp, %rsp
; nextln: popq %rbp
; nextln: ret

View File

@@ -11,7 +11,7 @@ block0(v0: i64, v1: i64):
v4 = bint.i64 v3
; nextln: cmpq %rax, %rdi
; nextln: setz %cl
; nextln: movzbq %cl, %rcx
; nextln: andq $$1, %rcx
v5 = select.i64 v3, v0, v1
; nextln: cmpq %rax, %rdi
@@ -34,7 +34,7 @@ block0(v0: f64, v1: i64):
; nextln: setnp %dil
; nextln: setz %sil
; nextln: andl %edi, %esi
; nextln: movzbq %sil, %rsi
; nextln: andq $$1, %rsi
v5 = select.f64 v3, v0, v0
; nextln: ucomisd %xmm1, %xmm0

View File

@@ -463,7 +463,8 @@ block0(v0: b1):
v1 = bint.i128 v0
return v1
; check: movzbq %dil, %rsi
; nextln: movq %rdi, %rsi
; nextln: andq $$1, %rsi
; nextln: xorq %rdi, %rdi
; nextln: movq %rsi, %rax
; nextln: movq %rdi, %rdx

View File

@@ -0,0 +1,37 @@
test run
target aarch64
target x86_64 machinst
function %bint_b8_i16_true() -> i16 {
block0:
v0 = bconst.b8 true
v1 = bint.i16 v0
return v1
}
; run: %bint_b8_i16_true() == 1
function %bint_b16_i16_true() -> i16 {
block0:
v0 = bconst.b16 true
v1 = bint.i16 v0
return v1
}
; run: %bint_b16_i16_true() == 1
function %bint_b8_i16_false() -> i16 {
block0:
v0 = bconst.b8 false
v1 = bint.i16 v0
return v1
}
; run: %bint_b8_i16_false() == 0
function %bint_b16_i16_false() -> i16 {
block0:
v0 = bconst.b16 false
v1 = bint.i16 v0
return v1
}
; run: %bint_b16_i16_false() == 0

View File

@@ -0,0 +1,11 @@
test run
target x86_64 machinst
function %bint_b8_i128() -> i64, i64 {
block0:
v0 = bconst.b8 true
v1 = bint.i128 v0
v2, v3 = isplit.i128 v1
return v2, v3
}
; run: %bint_b8_i128() == [1, 0]