Re-work X86 code generation of atomic ops with spin-loop
authorMichael Liao <michael.liao@intel.com>
Thu, 20 Sep 2012 03:06:15 +0000 (03:06 +0000)
committerMichael Liao <michael.liao@intel.com>
Thu, 20 Sep 2012 03:06:15 +0000 (03:06 +0000)
commitb118a073d7434727a4ea5a5762f54e54e72bef4f
tree93286fb22ddad2e10adcae4d28d7938958fe03a1
parent1141b5227ec1411b0ed624f8a243e1e25e27b55f
Re-work X86 code generation of atomic ops with spin-loop

- Rewrite/merge pseudo-atomic instruction emitters to address the
  following issue:
  * Reduce one unnecessary load in spin-loop

    previously the spin-loop looks like

        thisMBB:
        newMBB:
          ld  t1 = [bitinstr.addr]
          op  t2 = t1, [bitinstr.val]
          not t3 = t2  (if Invert)
          mov EAX = t1
          lcs dest = [bitinstr.addr], t3  [EAX is implicit]
          bz  newMBB
          fallthrough -->nextMBB

    the 'ld' at the beginning of newMBB should be lift out of the loop
    as lcs (or CMPXCHG on x86) will load the current memory value into
    EAX. This loop is refined as:

        thisMBB:
          EAX = LOAD [MI.addr]
        mainMBB:
          t1 = OP [MI.val], EAX
          LCMPXCHG [MI.addr], t1, [EAX is implicitly used & defined]
          JNE mainMBB
        sinkMBB:

  * Remove immopc as, so far, all pseudo-atomic instructions has
    all-register form only, there is no immedidate operand.

  * Remove unnecessary attributes/modifiers in pseudo-atomic instruction
    td

  * Fix issues in PR13458

- Add comprehensive tests on atomic ops on various data types.
  NOTE: Some of them are turned off due to missing functionality.

- Revise tests due to the new spin-loop generated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164281 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86InstrCompiler.td
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrInfo.h
test/CodeGen/X86/2010-01-08-Atomic64Bug.ll
test/CodeGen/X86/atomic16.ll [new file with mode: 0644]
test/CodeGen/X86/atomic32.ll [new file with mode: 0644]
test/CodeGen/X86/atomic64.ll [new file with mode: 0644]
test/CodeGen/X86/atomic6432.ll [new file with mode: 0644]
test/CodeGen/X86/atomic8.ll [new file with mode: 0644]
test/CodeGen/X86/atomic_op.ll
test/CodeGen/X86/pr13458.ll [new file with mode: 0644]