-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISLE: aarch64: fix narrow sdiv on intmin/-1 (#9541)
* Fix a missing trap on narrow sdiv of intmin/-1 by left-shifting before checking for intmin Co-authored-by: Michael McLoughlin <[email protected]> * Remove non-upstreamed verifier attributes --------- Co-authored-by: Michael McLoughlin <[email protected]>
- Loading branch information
1 parent
1499840
commit 025fea0
Showing
3 changed files
with
155 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
cranelift/filetests/filetests/isa/aarch64/trap_sdiv.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
test compile precise-output | ||
target aarch64 | ||
|
||
function %div8(i8, i8) -> i8 { | ||
block0(v0: i8, v1: i8): | ||
v2 = sdiv v0, v1 | ||
return v2 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; sxtb x3, w0 | ||
; sxtb x5, w1 | ||
; cbz x5, #trap=int_divz | ||
; lsl w8, w3, #24 | ||
; adds wzr, w5, #1 | ||
; ccmp w8, #1, #nzcv, eq | ||
; b.vs #trap=int_ovf | ||
; sdiv x0, x3, x5 | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; sxtb x3, w0 | ||
; sxtb x5, w1 | ||
; cbz x5, #0x24 | ||
; lsl w8, w3, #0x18 | ||
; cmn w5, #1 | ||
; ccmp w8, #1, #0, eq | ||
; b.vs #0x28 | ||
; sdiv x0, x3, x5 | ||
; ret | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_divz | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_ovf | ||
|
||
function %div16(i16, i16) -> i16 { | ||
block0(v0: i16, v1: i16): | ||
v2 = sdiv v0, v1 | ||
return v2 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; sxth x3, w0 | ||
; sxth x5, w1 | ||
; cbz x5, #trap=int_divz | ||
; lsl w8, w3, #16 | ||
; adds wzr, w5, #1 | ||
; ccmp w8, #1, #nzcv, eq | ||
; b.vs #trap=int_ovf | ||
; sdiv x0, x3, x5 | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; sxth x3, w0 | ||
; sxth x5, w1 | ||
; cbz x5, #0x24 | ||
; lsl w8, w3, #0x10 | ||
; cmn w5, #1 | ||
; ccmp w8, #1, #0, eq | ||
; b.vs #0x28 | ||
; sdiv x0, x3, x5 | ||
; ret | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_divz | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_ovf | ||
|
||
function %div32(i32, i32) -> i32 { | ||
block0(v0: i32, v1: i32): | ||
v2 = sdiv v0, v1 | ||
return v2 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; sxtw x3, w0 | ||
; sxtw x5, w1 | ||
; cbz x5, #trap=int_divz | ||
; adds wzr, w5, #1 | ||
; ccmp w3, #1, #nzcv, eq | ||
; b.vs #trap=int_ovf | ||
; sdiv x0, x3, x5 | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; sxtw x3, w0 | ||
; sxtw x5, w1 | ||
; cbz x5, #0x20 | ||
; cmn w5, #1 | ||
; ccmp w3, #1, #0, eq | ||
; b.vs #0x24 | ||
; sdiv x0, x3, x5 | ||
; ret | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_divz | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_ovf | ||
|
||
function %div64(i64, i64) -> i64 { | ||
block0(v0: i64, v1: i64): | ||
v2 = sdiv v0, v1 | ||
return v2 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; cbz x1, #trap=int_divz | ||
; adds xzr, x1, #1 | ||
; ccmp x0, #1, #nzcv, eq | ||
; b.vs #trap=int_ovf | ||
; sdiv x0, x0, x1 | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; cbz x1, #0x18 | ||
; cmn x1, #1 | ||
; ccmp x0, #1, #0, eq | ||
; b.vs #0x1c | ||
; sdiv x0, x0, x1 | ||
; ret | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_divz | ||
; .byte 0x1f, 0xc1, 0x00, 0x00 ; trap: int_ovf | ||
|