MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / is_power2

Function is_power2

smt/expr.cpp:64–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64static bool is_power2(const expr &e, unsigned &log) {
65 if (!e.isConst())
66 return false;
67
68 if (e.isZero() || !(e & (e - expr::mkUInt(1, e))).isZero())
69 return false;
70
71 for (unsigned i = 0, bits = e.bits(); i < bits; ++i) {
72 if (e.extract(i, i).isAllOnes()) {
73 log = i;
74 return true;
75 }
76 }
77 UNREACHABLE();
78}
79
80
81namespace smt {

Callers 6

operator*Method · 0.70
uremMethod · 0.70
operator&Method · 0.70
zeroBitsShortOffsetMethod · 0.50
isAlignedMethod · 0.50
getExactAlignMethod · 0.50

Calls 5

isAllOnesMethod · 0.80
isConstMethod · 0.45
isZeroMethod · 0.45
bitsMethod · 0.45
extractMethod · 0.45

Tested by

no test coverage detected