[PATCH] D17633: [X86] Reuse EFLAGS and form LOCKed ops when only user is SETCC.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 18:23:39 PST 2016
ab created this revision.
ab added a reviewer: t.p.northover.
ab added subscribers: llvm-commits, jfb, qcolombet.
We only generate LOCKed versions of add/sub when the result is unused. It often happens that the result is used, but only by a comparison. We can optimize those out by reusing EFLAGS, which lets us use the proper instructions, instead of having to fallback to LXADD.
Instead of doing this as an MI peephole (as we do for the other non-LOCKed (really, non-MR) forms), do it in ISel. It becomes quite tricky later.
This also makes it possible to stop expanding and/or/xor if the only user is an icmp. I'm a little uncomfortable with the coupling, but I can send a patch if there are no objections?
Note that this builds on several local patches that I can commit right now if desired: I moved the LOCK isel from DAGToDAG to ISelLowering and tablegen. I added the atomic-eflags-update.ll file and split it out to make it easier to review; I'll squash it when committing.
Also, I locally added a combine to canonicalize (LSUB x, c) to (LADD x, -c), but only if c is 1 (to simplify matching INC/DEC). Any objections to generalizing that to any constant? (we do the same for ISD::SUB).
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7387 bytes
Desc: not available
More information about the llvm-commits