Not sure where the IF would come in?
Assuming #cpuCount already exists and you want to include any data in there in your sum:
insert #cpuCount select CPU from Machine where PROD = 'Y'
go
select sum(CPU) from #cpuCount
go
Assuming #cpuCount doesn't exist:
select CPU into #cpuCount from Machine where PROD = 'Y'
go
select sum(CPU) from #cpuCount