diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 5046925fd..2a9c6a9ea 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1537,6 +1537,15 @@ string IRGeneratorForStatements::binaryOperation( case Token::Mod: fun = m_utils.checkedIntModFunction(*type); break; + case Token::BitOr: + fun = "or"; + break; + case Token::BitXor: + fun = "xor"; + break; + case Token::BitAnd: + fun = "and"; + break; default: break; } diff --git a/test/libsolidity/semanticTests/expressions/bit_operators.sol b/test/libsolidity/semanticTests/expressions/bit_operators.sol new file mode 100644 index 000000000..32ec16bf6 --- /dev/null +++ b/test/libsolidity/semanticTests/expressions/bit_operators.sol @@ -0,0 +1,19 @@ +contract test { + uint8 x; + uint v; + function f() public returns (uint x, uint y, uint z) { + uint16 a; + uint32 b; + assembly { + a := 0x0f0f0f0f0f + b := 0xff0fff0fff + } + x = a & b; + y = a | b; + z = a ^ b; + } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 3855, 268374015, 268370160