Is bitwise operators supported in TVM?

I’m trying to write something as follows using IR builder:
with ib.for_range(0, size - 1, name = “level”, for_type = “unroll”) as level:
with ib.if_scope(tid % 2 == (1 & level)):
with ib.if_scope((~(is_descend ^ (p_data_new[tid] < p_data_new[tid + 1])))):

But TVM gives me errors as follows:
TypeError: unsupported operand type(s) for &: ‘int’ and ‘Var’
TypeError: unsupported operand type(s) for ^: ‘bool’ and ‘LT’

What’s the correct way of using bitwise operators here?

Might be due to mixing of types? (Don’t know what happens with Python int, Python bool here)

bitwise ops are defined in (not sure if relevant)

I think @eqy is right, you might need to explicitly convert the result of compare into into the int32 type before bitwise operation

I did
result = (p_data_new[tid] < p_data_new[tid + 1]).astype(‘int32’)
with ib.if_scope(~(is_descend ^ result)):

But it still gives me an error of “TypeError: unsupported operand type(s) for ^: ‘bool’ and ‘Cast’”

Am I doing the xnor correctly this way?

It works after I switch the order of (p_data_new[tid] < p_data_new[tid + 1]) and is_descend for ‘^’ operation