The performance difference is very marginal. So get the Athlon II X4 645 and saves the extra money. You can always overclock it to Phenom II X4 840 level to get the same performance. 840 is not a true phenom II, it is a re-branded Athlon II without L3 cache.
Performance wise both of them are neck to neck
AMD Phenom II X4 840 3.20 GHz Review - Page 1/12 | techPowerUp
so getting Athlon Ii X4 645 makes more sense for it's low price tag but for a better one just get a Phenom II 955BE