[codegen] Don't simplify an operation if it would result in unnecessary legalization;
Converting something like iadd.i64 on a 32-bits architecture into a iadd_imm.i64 will result in the instruction being legalized back to an iadd.i64 later on, creating unnecessary churn. This commit implements avoid doing so, and changes the target ISA to a 64-bits platform for tests than ran into this, as well as making sure this won't happen on 32-bits platforms.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
test simple_preopt
|
||||
target i686 baseline
|
||||
target x86_64 baseline
|
||||
|
||||
; Cases where the denominator is created by an iconst
|
||||
|
||||
|
||||
61
cranelift/filetests/filetests/simple_preopt/simplify32.clif
Normal file
61
cranelift/filetests/filetests/simple_preopt/simplify32.clif
Normal file
@@ -0,0 +1,61 @@
|
||||
test simple_preopt
|
||||
target i686
|
||||
|
||||
;; 32-bits platforms.
|
||||
|
||||
function %iadd_imm(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
v1 = iconst.i32 2
|
||||
v2 = iadd v0, v1
|
||||
return v2
|
||||
}
|
||||
; sameln: function %iadd_imm
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v1 = iconst.i32 2
|
||||
; nextln: v2 = iadd_imm v0, 2
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
|
||||
function %isub_imm(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
v1 = iconst.i32 2
|
||||
v2 = isub v0, v1
|
||||
return v2
|
||||
}
|
||||
; sameln: function %isub_imm
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v1 = iconst.i32 2
|
||||
; nextln: v2 = iadd_imm v0, -2
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
|
||||
function %icmp_imm(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
v1 = iconst.i32 2
|
||||
v2 = icmp slt v0, v1
|
||||
v3 = bint.i32 v2
|
||||
return v3
|
||||
}
|
||||
; sameln: function %icmp_imm
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v1 = iconst.i32 2
|
||||
; nextln: v2 = icmp_imm slt v0, 2
|
||||
; nextln: v3 = bint.i32 v2
|
||||
; nextln: return v3
|
||||
; nextln: }
|
||||
|
||||
;; Don't simplify operations that would get illegal because of lack of native
|
||||
;; support.
|
||||
function %iadd_imm(i64) -> i64 {
|
||||
ebb0(v0: i64):
|
||||
v1 = iconst.i64 2
|
||||
v2 = iadd v0, v1
|
||||
return v2
|
||||
}
|
||||
; sameln: function %iadd_imm
|
||||
; nextln: ebb0(v0: i64):
|
||||
; nextln: v1 = iconst.i64 2
|
||||
; nextln: v2 = iadd v0, v1
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
test simple_preopt
|
||||
target i686
|
||||
target x86_64
|
||||
|
||||
;; 64-bits platforms.
|
||||
|
||||
function %iadd_imm(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
Reference in New Issue
Block a user