private static boolean matchWithPossibleExtension(long val1, int size, long extendval) {
		if (extendval >= 0) {			// If there was an extension, it was a zero extension
			return (val1 == extendval);
		}
		// Possible sign extension
		long mask = -1;
		mask >>>= (8 - size) * 8;
		long maskcomp = ~mask;
		maskcomp >>= 1;			// Add bit that we are extending from
		if ((extendval & maskcomp) != maskcomp) {	// Make sure sign-extension is consistent
			return false;
		}
		return (val1 == (mask & extendval));
	}
Test that extendval is equal to val1, where extendval may be an extension
@param val1  is the value that needs to be matched
@param size  is the number of bytes in the value to be matched
@param extendval is the possibly extended value
@return true if they are equal
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java