Density fluctuations in amorphous and semicrystalline polymers