ARM & AArch64: make use of common cmpxchg idioms after expansion
authorTim Northover <tnorthover@apple.com>
Fri, 30 May 2014 10:09:59 +0000 (10:09 +0000)
committerTim Northover <tnorthover@apple.com>
Fri, 30 May 2014 10:09:59 +0000 (10:09 +0000)
commitd0dbe02fd26d47ed32c9e04a2a0385b26a49f4ed
tree9ca25621a85c9af7e635fcebf3774ce33b6da7ae
parent7be505ae8877d99d761da08952afbe74bacdae9e
ARM & AArch64: make use of common cmpxchg idioms after expansion

The C and C++ semantics for compare_exchange require it to return a bool
indicating success. This gets mapped to LLVM IR which follows each cmpxchg with
an icmp of the value loaded against the desired value.

When lowered to ldxr/stxr loops, this extra comparison is redundant: its
results are implicit in the control-flow of the function.

This commit makes two changes: it replaces that icmp with appropriate PHI
nodes, and then makes sure earlyCSE is called after expansion to actually make
use of the opportunities revealed.

I've also added -{arm,aarch64}-enable-atomic-tidy options, so that
existing fragile tests aren't perturbed too much by the change. Many
of them either rely on undef/unreachable too pervasively to be
restored to something well-defined (particularly while making sure
they test the same obscure assert from many years ago), or depend on a
particular CFG shape, which is disrupted by SimplifyCFG.

rdar://problem/16227836

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209883 91177308-0d34-0410-b5e6-96231b3b80d8
59 files changed:
lib/CodeGen/AtomicExpandLoadLinkedPass.cpp
lib/Target/AArch64/AArch64TargetMachine.cpp
lib/Target/ARM/ARMTargetMachine.cpp
test/CodeGen/AArch64/addsub_ext.ll
test/CodeGen/AArch64/arm64-ands-bad-peephole.ll
test/CodeGen/AArch64/arm64-cse.ll
test/CodeGen/AArch64/arm64-early-ifcvt.ll
test/CodeGen/AArch64/arm64-fp128.ll
test/CodeGen/AArch64/arm64-frame-index.ll
test/CodeGen/AArch64/arm64-xaluo.ll
test/CodeGen/AArch64/atomic-ops.ll
test/CodeGen/AArch64/blockaddress.ll
test/CodeGen/AArch64/breg.ll
test/CodeGen/AArch64/cmpxchg-idioms.ll [new file with mode: 0644]
test/CodeGen/AArch64/directcond.ll
test/CodeGen/AArch64/flags-multiuse.ll
test/CodeGen/AArch64/jump-table.ll
test/CodeGen/AArch64/ldst-opt.ll
test/CodeGen/AArch64/tst-br.ll
test/CodeGen/ARM/2009-11-02-NegativeLane.ll
test/CodeGen/ARM/2009-11-07-SubRegAsmPrinting.ll
test/CodeGen/ARM/2010-10-25-ifcvt-ldm.ll
test/CodeGen/ARM/2011-02-04-AntidepMultidef.ll
test/CodeGen/ARM/2012-11-14-subs_carry.ll
test/CodeGen/ARM/2013-07-29-vector-or-combine.ll
test/CodeGen/ARM/arm-and-tst-peephole.ll
test/CodeGen/ARM/atomic-64bit.ll
test/CodeGen/ARM/call-tc.ll
test/CodeGen/ARM/cmpxchg-idioms.ll [new file with mode: 0644]
test/CodeGen/ARM/data-in-code-annotations.ll
test/CodeGen/ARM/fptoint.ll
test/CodeGen/ARM/ifcvt-branch-weight.ll
test/CodeGen/ARM/ifcvt10.ll
test/CodeGen/ARM/indirectbr-3.ll
test/CodeGen/ARM/lsr-unfolded-offset.ll
test/CodeGen/ARM/misched-copy-arm.ll
test/CodeGen/ARM/reg_sequence.ll
test/CodeGen/ARM/spill-q.ll
test/CodeGen/ARM/struct-byval-frame-index.ll
test/CodeGen/ARM/twoaddrinstr.ll
test/CodeGen/ARM/vldm-sched-a9.ll
test/CodeGen/Thumb2/2009-08-01-WrongLDRBOpc.ll
test/CodeGen/Thumb2/2009-08-06-SpDecBug.ll
test/CodeGen/Thumb2/2009-09-28-ITBlockBug.ll
test/CodeGen/Thumb2/2010-04-15-DynAllocBug.ll
test/CodeGen/Thumb2/2010-06-21-TailMergeBug.ll
test/CodeGen/Thumb2/2010-11-22-EpilogueBug.ll
test/CodeGen/Thumb2/2011-06-07-TwoAddrEarlyClobber.ll
test/CodeGen/Thumb2/buildvector-crash.ll
test/CodeGen/Thumb2/cross-rc-coalescing-2.ll
test/CodeGen/Thumb2/ldr-str-imm12.ll
test/CodeGen/Thumb2/thumb2-branch.ll
test/CodeGen/Thumb2/thumb2-cbnz.ll
test/CodeGen/Thumb2/thumb2-ifcvt2.ll
test/CodeGen/Thumb2/thumb2-ifcvt3.ll
test/CodeGen/Thumb2/thumb2-spill-q.ll
test/CodeGen/Thumb2/v8_IT_3.ll
test/CodeGen/Thumb2/v8_IT_5.ll
test/Transforms/LoopStrengthReduce/ARM/2012-06-15-lsr-noaddrmode.ll