------- Comment #15 from hjl dot tools at gmail dot com 2010-06-10 15:43 ------- (In reply to comment #14) > (In reply to comment #11) > > > ADD is always faster than LEA for adding a register. However > > there is a special case on Atom where ADD should be avoided. > > It is true that LEA doesn't touch flags and we used it instead > > of ADD which touches flags. It is an optimization specific for > > Atom. You can think it as a special ADD for Atom and pretend > > it clobbers flags. We shouldn't model it as a real LEA since > > it is used to implement a faster ADD in this special case. > > LEA can also implement true three-operand add (rX = rY + rZ), so it can save a > move. Expansion of three operands is effectively disabled due to usage of > ix86_binary_operand_ok in PLUS patterns, so split to LEA certainly has some > benefit. >
We only want to use LEAD instead ADD for rX += rY under certain conditions. As I said, ADD is faster than LEA in most cases. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44470