Skip to content

Commit

Permalink
Remove unreachable x64 lowerings for iadd_imm (bytecodealliance#4726)
Browse files Browse the repository at this point in the history
All of the `*_imm` instructions are rewritten during legalization to an
explicit `iconst` plus the general form of the operator, so backends
never see them. Therefore these ISLE rules in the x64 backend can never
match anything.
  • Loading branch information
jameysharp authored Aug 16, 2022
1 parent 5add267 commit c569e7b
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions cranelift/codegen/src/isa/x64/lower.isle
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,6 @@

;; (No `iadd_ifcout` for `i128`.)

;;;; Rules for `iadd_imm` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; `i64` and smaller.

;; When the immediate fits in a `RegMemImm.Imm`, use that.
(rule (lower (has_type (fits_in_64 ty) (iadd_imm y (simm32_from_imm64 x))))
(x64_add ty y x))

;; Otherwise, put the immediate into a register.
(rule (lower (has_type (fits_in_64 ty) (iadd_imm y (u64_from_imm64 x))))
(x64_add ty y (imm ty x)))

;; `i128`

;; When the immediate fits in a `RegMemImm.Imm`, use that.
(rule (lower (has_type $I128 (iadd_imm y (simm32_from_imm64 x))))
(let ((y_regs ValueRegs y)
(y_lo Gpr (value_regs_get_gpr y_regs 0))
(y_hi Gpr (value_regs_get_gpr y_regs 1)))
(with_flags (x64_add_with_flags_paired $I64 y_lo x)
(x64_adc_paired $I64 y_hi (RegMemImm.Imm 0)))))

;; Otherwise, put the immediate into a register.
(rule (lower (has_type $I128 (iadd_imm y (u64_from_imm64 x))))
(let ((y_regs ValueRegs y)
(y_lo Gpr (value_regs_get_gpr y_regs 0))
(y_hi Gpr (value_regs_get_gpr y_regs 1))
(x_lo Gpr (imm $I64 x)))
(with_flags (x64_add_with_flags_paired $I64 y_lo x_lo)
(x64_adc_paired $I64 y_hi (RegMemImm.Imm 0)))))

;;;; Rules for `isub` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; `i64` and smaller.
Expand Down

0 comments on commit c569e7b

Please sign in to comment.