Skip to content

Commit e70124e

Browse files
committed
[Cranelift] (-X) * C = X * (-C)
1 parent 66871ec commit e70124e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cranelift/codegen/src/opts/arithmetic.isle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,3 +500,6 @@
500500
(rule (simplify (ugt ty x (umax ty y x))) (iconst_u ty 0))
501501
(rule (simplify (ult ty (umax ty x y) x)) (iconst_u ty 0))
502502
(rule (simplify (ult ty (umax ty y x) x)) (iconst_u ty 0))
503+
504+
;; (-X) * C = X * (-C)
505+
(rule (simplify (imul (fits_in_64 ty) (ineg ty x) (iconst ty y))) (imul ty x (iconst ty (imm64_neg ty y))))

0 commit comments

Comments
 (0)