@@ -198,11 +198,33 @@ add_tfunc(div_float_fast, 2, 2, math_tfunc, 2)
198198# bitwise operators
199199# -----------------
200200
201+ @nospecs and_int_tfunc (𝕃:: AbstractLattice , x, y) = and_int_tfunc (widenlattice (𝕃), x, y)
202+ @nospecs function and_int_tfunc (𝕃:: ConstsLattice , x, y)
203+ if isa (x, Const) && x. val === false && widenconst (y) === Bool
204+ return Const (false )
205+ elseif isa (y, Const) && y. val === false && widenconst (x) === Bool
206+ return Const (false )
207+ end
208+ return and_int_tfunc (widenlattice (𝕃), x, y)
209+ end
210+ @nospecs and_int_tfunc (:: JLTypeLattice , x, y) = widenconst (x)
211+
212+ @nospecs or_int_tfunc (𝕃:: AbstractLattice , x, y) = or_int_tfunc (widenlattice (𝕃), x, y)
213+ @nospecs function or_int_tfunc (𝕃:: ConstsLattice , x, y)
214+ if isa (x, Const) && x. val === true && widenconst (y) === Bool
215+ return Const (true )
216+ elseif isa (y, Const) && y. val === true && widenconst (x) === Bool
217+ return Const (true )
218+ end
219+ return or_int_tfunc (widenlattice (𝕃), x, y)
220+ end
221+ @nospecs or_int_tfunc (:: JLTypeLattice , x, y) = widenconst (x)
222+
201223@nospecs shift_tfunc (𝕃:: AbstractLattice , x, y) = shift_tfunc (widenlattice (𝕃), x, y)
202224@nospecs shift_tfunc (:: JLTypeLattice , x, y) = widenconst (x)
203225
204- add_tfunc (and_int, 2 , 2 , math_tfunc , 1 )
205- add_tfunc (or_int, 2 , 2 , math_tfunc , 1 )
226+ add_tfunc (and_int, 2 , 2 , and_int_tfunc , 1 )
227+ add_tfunc (or_int, 2 , 2 , or_int_tfunc , 1 )
206228add_tfunc (xor_int, 2 , 2 , math_tfunc, 1 )
207229add_tfunc (not_int, 1 , 1 , math_tfunc, 0 ) # usually used as not_int(::Bool) to negate a condition
208230add_tfunc (shl_int, 2 , 2 , shift_tfunc, 1 )
0 commit comments