File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 235235(rule (simplify (bor ty (bnot ty (bxor ty x y)) (band ty y x))) (bnot ty (bxor ty x y)))
236236(rule (simplify (bor ty (band ty y x) (bnot ty (bxor ty y x)))) (bnot ty (bxor ty x y)))
237237(rule (simplify (bor ty (bnot ty (bxor ty y x)) (band ty y x))) (bnot ty (bxor ty x y)))
238+
239+ ; (x | y) + (-y) --> x & ~y
240+ (rule (simplify (iadd ty (bor ty x y) (ineg ty y)))
241+ (band ty x (bnot ty y)))
242+ (rule (simplify (iadd ty (ineg ty y) (bor ty x y)))
243+ (band ty x (bnot ty y)))
244+ (rule (simplify (iadd ty (bor ty y x) (ineg ty y)))
245+ (band ty x (bnot ty y)))
246+ (rule (simplify (iadd ty (ineg ty y) (bor ty y x)))
247+ (band ty x (bnot ty y)))
248+
249+
Original file line number Diff line number Diff line change @@ -89,4 +89,21 @@ block0(v0: i32, v1: i32):
8989; v6 = bxor v1, v0
9090; v7 = bnot v6
9191; return v7
92- ; }
92+ ; }
93+
94+ ;; (iadd ty (bor ty x y) (ineg ty y)) -> (band ty x (bnot ty y))
95+ function %test_iadd_bor_ineg(i32, i32) -> i32 fast {
96+ block0(v0: i32, v1: i32):
97+ v2 = bor v0, v1
98+ v3 = ineg v1
99+ v4 = iadd v2, v3
100+ return v4
101+ }
102+
103+ ; function %test_iadd_bor_ineg(i32, i32) -> i32 fast {
104+ ; block0(v0: i32, v1: i32):
105+ ; v2 = bor v0, v1
106+ ; v7 = isub v2, v1
107+ ; return v7
108+ ; }
109+
Original file line number Diff line number Diff line change @@ -244,4 +244,17 @@ block0(v0: i32, v1: i32):
244244; run: %test_bor_band_bnot_bxor(0, 0) == 0xffffffff
245245; run: %test_bor_band_bnot_bxor(1, 1) == 0xffffffff
246246; run: %test_bor_band_bnot_bxor(0, 1) == 0xfffffffe
247- ; run: %test_bor_band_bnot_bxor(2, 1) == 0xfffffffc
247+ ; run: %test_bor_band_bnot_bxor(2, 1) == 0xfffffffc
248+
249+ function %test_iadd_bor_ineg(i32, i32) -> i32 fast {
250+ block0(v0: i32, v1: i32):
251+ v2 = bor v0, v1
252+ v3 = ineg v1
253+ v4 = iadd v2, v3
254+ return v4
255+ }
256+
257+ ; run: %test_iadd_bor_ineg(0, 0) == 0
258+ ; run: %test_iadd_bor_ineg(1, 1) == 0
259+ ; run: %test_iadd_bor_ineg(2, 1) == 2
260+ ; run: %test_iadd_bor_ineg(0xffffffff, 0) == -1
You can’t perform that action at this time.
0 commit comments