Diphoton production at the LHC: a QCD study up to NNLO