diff -r b156fd0a4607 -r 675d857f5ee3 src/hotspot/share/opto/regmask.cpp --- a/src/hotspot/share/opto/regmask.cpp Wed Jan 23 10:23:05 2019 +0100 +++ b/src/hotspot/share/opto/regmask.cpp Wed Jan 23 10:01:21 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ #include "opto/matcher.hpp" #include "opto/node.hpp" #include "opto/regmask.hpp" +#include "utilities/population_count.hpp" #define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */ @@ -62,7 +63,7 @@ } // Find highest 1, or return 32 if empty -int find_hihghest_bit( uint32_t mask ) { +int find_highest_bit( uint32_t mask ) { int n = 0; if( mask > 0xffff ) { mask >>= 16; @@ -140,21 +141,6 @@ return 1; } -//------------------------------find_first_pair-------------------------------- -// Find the lowest-numbered register pair in the mask. Return the -// HIGHEST register number in the pair, or BAD if no pairs. -OptoReg::Name RegMask::find_first_pair() const { - verify_pairs(); - for( int i = 0; i < RM_SIZE; i++ ) { - if( _A[i] ) { // Found some bits - int bit = _A[i] & -_A[i]; // Extract low bit - // Convert to bit number, return hi bit in pair - return OptoReg::Name((i<<_LogWordBits)+find_lowest_bit(bit)+1); - } - } - return OptoReg::Bad; -} - //------------------------------ClearToPairs----------------------------------- // Clear out partial bits; leave only bit pairs void RegMask::clear_to_pairs() { @@ -167,18 +153,6 @@ verify_pairs(); } -//------------------------------SmearToPairs----------------------------------- -// Smear out partial bits; leave only bit pairs -void RegMask::smear_to_pairs() { - for( int i = 0; i < RM_SIZE; i++ ) { - int bits = _A[i]; - bits |= ((bits & 0x55555555)<<1); // Smear lo bit hi per pair - bits |= ((bits & 0xAAAAAAAA)>>1); // Smear hi bit lo per pair - _A[i] = bits; - } - verify_pairs(); -} - //------------------------------is_aligned_pairs------------------------------- bool RegMask::is_aligned_pairs() const { // Assert that the register mask contains only bit pairs. @@ -389,14 +363,10 @@ //------------------------------Size------------------------------------------- // Compute size of register mask in bits uint RegMask::Size() const { - extern uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE]; uint sum = 0; - for( int i = 0; i < RM_SIZE; i++ ) - sum += - bitsInByte[(_A[i]>>24) & 0xff] + - bitsInByte[(_A[i]>>16) & 0xff] + - bitsInByte[(_A[i]>> 8) & 0xff] + - bitsInByte[ _A[i] & 0xff]; + for (int i = 0; i < RM_SIZE; i++) { + sum += population_count(_A[i]); + } return sum; }