Browse Source
Terminate blocks with a single branch in riscv64 (#5374)
Ensure that we're terminating blocks with a single branch instruction, when testing I128 values against zero.
pull/5377/head
Trevor Elliott
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
17 additions and
3 deletions
-
cranelift/codegen/src/isa/riscv64/inst.isle
-
cranelift/filetests/filetests/isa/riscv64/condbr.clif
|
|
@ -1921,6 +1921,13 @@ |
|
|
|
(lower_branch (brz v @ (value_type ty) _ _) targets) |
|
|
|
(lower_brz_or_nz (IntCC.Equal) (normalize_cmp_value ty v) targets ty)) |
|
|
|
|
|
|
|
;; Special case for SI128 to reify the comparison value and branch on it. |
|
|
|
(rule 2 |
|
|
|
(lower_branch (brz v @ (value_type $I128) _ _) targets) |
|
|
|
(let ((zero ValueRegs (value_regs (zero_reg) (zero_reg))) |
|
|
|
(cmp Reg (gen_icmp (IntCC.Equal) v zero $I128))) |
|
|
|
(lower_brz_or_nz (IntCC.NotEqual) cmp targets $I64))) |
|
|
|
|
|
|
|
(rule 1 |
|
|
|
(lower_branch (brz (icmp cc a @ (value_type ty) b) _ _) targets) |
|
|
|
(lower_br_icmp (intcc_inverse cc) a b targets ty)) |
|
|
@ -1934,6 +1941,13 @@ |
|
|
|
(lower_branch (brnz v @ (value_type ty) _ _) targets) |
|
|
|
(lower_brz_or_nz (IntCC.NotEqual) (normalize_cmp_value ty v) targets ty)) |
|
|
|
|
|
|
|
;; Special case for SI128 to reify the comparison value and branch on it. |
|
|
|
(rule 2 |
|
|
|
(lower_branch (brnz v @ (value_type $I128) _ _) targets) |
|
|
|
(let ((zero ValueRegs (value_regs (zero_reg) (zero_reg))) |
|
|
|
(cmp Reg (gen_icmp (IntCC.NotEqual) v zero $I128))) |
|
|
|
(lower_brz_or_nz (IntCC.NotEqual) cmp targets $I64))) |
|
|
|
|
|
|
|
(rule 1 |
|
|
|
(lower_branch (brnz (icmp cc a @ (value_type ty) b) _ _) targets) |
|
|
|
(lower_br_icmp cc a b targets ty)) |
|
|
|
|
|
@ -170,8 +170,8 @@ block1: |
|
|
|
} |
|
|
|
|
|
|
|
; block0: |
|
|
|
; bne a1,zero,taken(label2),not_taken(0) |
|
|
|
; beq a0,zero,taken(label1),not_taken(label2) |
|
|
|
; eq a0,[a0,a1],[zerozero]##ty=i128 |
|
|
|
; bne a0,zero,taken(label1),not_taken(label2) |
|
|
|
; block1: |
|
|
|
; j label3 |
|
|
|
; block2: |
|
|
@ -190,7 +190,7 @@ block1: |
|
|
|
} |
|
|
|
|
|
|
|
; block0: |
|
|
|
; bne a1,zero,taken(label1),not_taken(0) |
|
|
|
; ne a0,[a0,a1],[zerozero]##ty=i128 |
|
|
|
; bne a0,zero,taken(label1),not_taken(label2) |
|
|
|
; block1: |
|
|
|
; j label3 |
|
|
|