aarch64: Fix incorrect encoding of large const values in icmp.
When encoding constants as immediates into an RSE Imm12 instruction we need to take special care to check if the value that we are trying to input does not overflow its type when viewed as a signed value. (i.e. iconst.i8 200) We cannot both put an immediate and sign extend it, so we need to lower it into a separate reg, and emit the sign extend into the instruction. For more details see the [cg_clif bug report](https://github.com/bjorn3/rustc_codegen_cranelift/issues/1184#issuecomment-873214796).
This commit is contained in:
17
cranelift/filetests/filetests/runtests/icmp.clif
Normal file
17
cranelift/filetests/filetests/runtests/icmp.clif
Normal file
@@ -0,0 +1,17 @@
|
||||
test run
|
||||
target aarch64
|
||||
target s390x
|
||||
target x86_64 machinst
|
||||
|
||||
; This test is also a regression test for aarch64.
|
||||
; We were not correctly handling the fact that the rhs constant value
|
||||
; overflows its type when viewed as a signed value, and thus encoding the wrong
|
||||
; value into the resulting instruction.
|
||||
function %overflow_rhs_const(i8) -> b1 {
|
||||
block0(v0: i8):
|
||||
v1 = iconst.i8 192
|
||||
v2 = icmp sge v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %test(49) == true
|
||||
; run: %test(-65) == false
|
||||
Reference in New Issue
Block a user