[CodeGen] Add constexpr and static_assert to fold64To16 (#192864)
This ensures the folding logic stability.
This commit is contained in:
parent
b39dfca39f
commit
b906cf354b
1 changed files with 4 additions and 1 deletions
|
|
@ -38,7 +38,7 @@ static uint64_t hashBlock(const MachineBasicBlock &MBB, bool HashOperands) {
|
|||
}
|
||||
|
||||
/// Fold a 64-bit integer to a 16-bit one.
|
||||
static uint16_t fold_64_to_16(const uint64_t Value) {
|
||||
static constexpr uint16_t fold_64_to_16(const uint64_t Value) {
|
||||
uint16_t Res = static_cast<uint16_t>(Value);
|
||||
Res ^= static_cast<uint16_t>(Value >> 16);
|
||||
Res ^= static_cast<uint16_t>(Value >> 32);
|
||||
|
|
@ -46,6 +46,9 @@ static uint16_t fold_64_to_16(const uint64_t Value) {
|
|||
return Res;
|
||||
}
|
||||
|
||||
static_assert(fold_64_to_16(1) == 1);
|
||||
static_assert(fold_64_to_16(12345678) == 25074);
|
||||
|
||||
INITIALIZE_PASS(MachineBlockHashInfo, "machine-block-hash",
|
||||
"Machine Block Hash Analysis", true, true)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue