When splitting a const, insert prior to the terminal branch group. (#1325)

* When splitting a const, insert prior to the terminal branch group. Closes #1159

Given code like the following, on x86_64, which does not have i128 registers:

    ebb0(v0: i64):
        v1 = iconst.i128 0
        v2 = icmp_imm eq v0, 1
        brnz v2, ebb1
        jump ebb2(v1)

It would be split to:

    ebb0(v0: i64):
        v1 = iconst.i128 0
        v2 = icmp_imm eq v0, 1
        brnz v2, ebb1
        v3, v4 = isplit.i128 v1
        jump ebb2(v3, v4)

But that fails basic-block invariants. This patch changes that to:

    ebb0(v0: i64):
        v1 = iconst.i128 0
        v2 = icmp_imm eq v0, 1
        v3, v4 = isplit.i128 v1
        brnz v2, ebb1
        jump ebb2(v3, v4)

* Add isplit-bb.clif testcase
This commit is contained in:
Sean Stangl
2020-01-22 09:14:41 -07:00
committed by Benjamin Bouvier
parent d6134a6f3a
commit b4c6bfd371
3 changed files with 55 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
test compile
target x86_64
function u0:0(i128, i128, i64) -> i128 system_v {
ebb0(v0: i128, v1: i128, v2: i64):
trap user0
ebb1:
v10 = iconst.i64 0
v11 = iconst.i64 0
v17 = iconcat v10, v11
v12 = iconst.i64 0
v13 = iconst.i64 0
v20 = iconcat v12, v13
trap user0
ebb79:
v425 = iconst.i64 0
v426 = icmp_imm eq v425, 1
brnz v426, ebb80
jump ebb85(v20, v17)
ebb80:
trap user0
ebb85(v462: i128, v874: i128):
trap user0
}