Add ineg legalization for scalar integer types (#1385)

This commit is contained in:
Peter Delevoryas
2020-02-14 13:16:02 -08:00
committed by GitHub
parent 4d8cf563f3
commit 18b40d1101
6 changed files with 103 additions and 12 deletions

View File

@@ -90,3 +90,44 @@ block0(v0: f32, v1: f32):
; check: $done(v2: f32):
; nextln: return v2
}
function %ineg_legalized_i8() {
block0:
v0 = iconst.i8 1
v1 = ineg v0
; check: v2 = iconst.i32 1
; nextln: v0 = ireduce.i8 v2
; nextln: v3 = iconst.i8 0
; nextln: v4 = uextend.i32 v3
; nextln: v5 = uextend.i32 v0
; nextln: v6 = isub v4, v5
; nextln: v1 = ireduce.i8 v6
return
}
function %ineg_legalized_i16() {
block0:
v0 = iconst.i16 1
v1 = ineg v0
; check: v2 = iconst.i32 1
; nextln: v0 = ireduce.i16 v2
; nextln: v3 = iconst.i16 0
; nextln: v4 = uextend.i32 v3
; nextln: v5 = uextend.i32 v0
; nextln: v6 = isub v4, v5
; nextln: v1 = ireduce.i16 v6
return
}
function %ineg_legalized_i32() {
block0:
v0 = iconst.i32 1
v1 = ineg v0
; check: v0 = iconst.i32 1
; nextln: v2 = iconst.i32 0
; nextln: v1 = isub v2, v0
return
}

View File

@@ -338,3 +338,20 @@ block0(v1: i64):
; nextln: v10 = bor $b1, $c2
return v10
}
function %ineg_legalized_i64() {
block0:
v0 = iconst.i64 1
v1 = ineg v0
; check: v2 = iconst.i32 1
; nextln: v3 = iconst.i32 0
; nextln: v0 = iconcat v2, v3
; nextln: v5 = iconst.i32 0
; nextln: v6 = iconst.i32 0
; nextln: v4 = iconcat v5, v6
; nextln: v7, v8 = isub_ifbout v5, v2
; nextln: v9 = isub_ifbin v6, v3, v8
; nextln: v1 = iconcat v7, v9
return
}

View File

@@ -0,0 +1,13 @@
; Test the custom legalization of ineg.i64 on x86_64.
test legalizer
target x86_64
function %ineg_legalized_i64() {
block0:
v0 = iconst.i64 1
v1 = ineg v0
; check: v0 = iconst.i64 1
; nextln: v2 = iconst.i64 0
; nextln: v1 = isub v2, v0
return
}