nir: use sets instead of hash tables where we can