Add non-power-of-two check to GenericMath.