2014-05-08 22:06:24 +08:00
|
|
|
; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-none-linux-gnueabihf | FileCheck %s --check-prefix=CHECK-THUMB --check-prefix=CHECK-THUMB-LE
|
2014-12-18 10:20:58 +08:00
|
|
|
; RUN: llc < %s -mtriple=armebv7 -target-abi apcs | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
|
2014-05-08 22:06:24 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumbebv7-none-linux-gnueabihf | FileCheck %s --check-prefix=CHECK-THUMB --check-prefix=CHECK-THUMB-BE
|
2011-08-31 08:31:29 +08:00
|
|
|
|
|
|
|
define i64 @test1(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test1:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: adds [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
|
|
|
; CHECK-LE: adc [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE: adds [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE: adc [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
2011-08-31 08:31:29 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test1:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: adds.w [[REG3:[a-z0-9]+]], [[REG1]]
|
|
|
|
; CHECK-THUMB-LE: adc.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE: adds.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE: adc.w [[REG3:[a-z0-9]+]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-08-31 08:31:29 +08:00
|
|
|
%r = atomicrmw add i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test2(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test2:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: subs [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
|
|
|
; CHECK-LE: sbc [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE: subs [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE: sbc [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
2011-08-31 08:31:29 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test2:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: subs.w [[REG3:[a-z0-9]+]], [[REG1]]
|
|
|
|
; CHECK-THUMB-LE: sbc.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE: subs.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE: sbc.w [[REG3:[a-z0-9]+]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-08-31 08:31:29 +08:00
|
|
|
%r = atomicrmw sub i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test3(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test3:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE-DAG: and [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
|
|
|
; CHECK-LE-DAG: and [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE-DAG: and [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE-DAG: and [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
2011-08-31 08:31:29 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test3:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE-DAG: and.w [[REG3:[a-z0-9]+]], [[REG1]]
|
|
|
|
; CHECK-THUMB-LE-DAG: and.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE-DAG: and.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE-DAG: and.w [[REG3:[a-z0-9]+]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-08-31 08:31:29 +08:00
|
|
|
%r = atomicrmw and i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test4(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test4:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE-DAG: orr [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
|
|
|
; CHECK-LE-DAG: orr [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE-DAG: orr [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE-DAG: orr [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
2011-08-31 08:31:29 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test4:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE-DAG: orr.w [[REG3:[a-z0-9]+]], [[REG1]]
|
|
|
|
; CHECK-THUMB-LE-DAG: orr.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE-DAG: orr.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE-DAG: orr.w [[REG3:[a-z0-9]+]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-08-31 08:31:29 +08:00
|
|
|
%r = atomicrmw or i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test5(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test5:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE-DAG: eor [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
|
|
|
; CHECK-LE-DAG: eor [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE-DAG: eor [[REG4:(r[0-9]?[13579])]], [[REG2]]
|
|
|
|
; CHECK-BE-DAG: eor [[REG3:(r[0-9]?[02468])]], [[REG1]]
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
2011-08-31 08:31:29 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test5:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE-DAG: eor.w [[REG3:[a-z0-9]+]], [[REG1]]
|
|
|
|
; CHECK-THUMB-LE-DAG: eor.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE-DAG: eor.w [[REG4:[a-z0-9]+]], [[REG2]]
|
|
|
|
; CHECK-THUMB-BE-DAG: eor.w [[REG3:[a-z0-9]+]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-08-31 08:31:29 +08:00
|
|
|
%r = atomicrmw xor i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test6(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test6:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, {{r[0-9]?[02468]}}, {{r[0-9]?[13579]}}
|
2011-08-31 08:31:29 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test6:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, {{[a-z0-9]+}}, {{[a-z0-9]+}}
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-08-31 08:31:29 +08:00
|
|
|
%r = atomicrmw xchg i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
2011-08-31 08:41:05 +08:00
|
|
|
}
|
2011-09-01 01:52:22 +08:00
|
|
|
|
|
|
|
define i64 @test7(i64* %ptr, i64 %val1, i64 %val2) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test7:
|
2014-06-14 00:45:52 +08:00
|
|
|
; CHECK-DAG: mov [[VAL1LO:r[0-9]+]], r1
|
|
|
|
; CHECK-DAG: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-06-14 00:45:52 +08:00
|
|
|
; CHECK-LE-DAG: eor [[MISMATCH_LO:r[0-9]+]], [[REG1]], [[VAL1LO]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE-DAG: eor [[MISMATCH_HI:r[0-9]+]], [[REG2]], r2
|
|
|
|
; CHECK-BE-DAG: eor [[MISMATCH_LO:r[0-9]+]], [[REG2]], r2
|
|
|
|
; CHECK-BE-DAG: eor [[MISMATCH_HI:r[0-9]+]], [[REG1]], r1
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: orrs {{r[0-9]+}}, [[MISMATCH_LO]], [[MISMATCH_HI]]
|
2011-09-01 01:52:22 +08:00
|
|
|
; CHECK: bne
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, {{r[0-9]?[02468]}}, {{r[0-9]?[13579]}}
|
2011-09-01 01:52:22 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test7:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE-DAG: eor.w [[MISMATCH_LO:[a-z0-9]+]], [[REG1]], r2
|
|
|
|
; CHECK-THUMB-LE-DAG: eor.w [[MISMATCH_HI:[a-z0-9]+]], [[REG2]], r3
|
2014-05-30 18:09:59 +08:00
|
|
|
; CHECK-THUMB-BE-DAG: eor.w [[MISMATCH_HI:[a-z0-9]+]], [[REG1]], r2
|
|
|
|
; CHECK-THUMB-BE-DAG: eor.w [[MISMATCH_LO:[a-z0-9]+]], [[REG2]], r3
|
|
|
|
; CHECK-THUMB-LE: orrs [[MISMATCH_HI]], [[MISMATCH_LO]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: bne
|
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, {{[a-z0-9]+}}, {{[a-z0-9]+}}
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
llvm-svn: 210903
2014-06-13 22:24:07 +08:00
|
|
|
%pair = cmpxchg i64* %ptr, i64 %val1, i64 %val2 seq_cst seq_cst
|
|
|
|
%r = extractvalue { i64, i1 } %pair, 0
|
2011-09-01 01:52:22 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
2011-09-01 02:26:09 +08:00
|
|
|
|
2013-09-26 20:22:36 +08:00
|
|
|
; Compiles down to a single ldrexd
|
2011-09-01 02:26:09 +08:00
|
|
|
define i64 @test8(i64* %ptr) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test8:
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test8:
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%r = load atomic i64, i64* %ptr seq_cst, align 8
|
2011-09-01 02:26:09 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
; Compiles down to atomicrmw xchg; there really isn't any more efficient
|
|
|
|
; way to write it.
|
|
|
|
define void @test9(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test9:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-17 05:55:34 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, {{r[0-9]?[02468]}}, {{r[0-9]?[13579]}}
|
2011-09-01 02:26:09 +08:00
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test9:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, {{[a-z0-9]+}}, {{[a-z0-9]+}}
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2011-09-01 02:26:09 +08:00
|
|
|
store atomic i64 %val, i64* %ptr seq_cst, align 8
|
|
|
|
ret void
|
|
|
|
}
|
2012-11-29 22:41:25 +08:00
|
|
|
|
|
|
|
define i64 @test10(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test10:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: mov [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[CARRY_HI:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[OUT_HI:[a-z0-9]+]], r2
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG1]], r1
|
|
|
|
; CHECK-BE: cmp [[REG2]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwls [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG2]], r2
|
|
|
|
; CHECK-BE: cmp [[REG1]], r1
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwle [[CARRY_HI]], #1
|
|
|
|
; CHECK: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK: mov [[OUT_LO:[a-z0-9]+]], r1
|
|
|
|
; CHECK: movne [[OUT_LO]], [[REG1]]
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test10:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB: mov.w [[CARRY_LO:[a-z0-9]+|lr]], #0
|
|
|
|
; CHECK-THUMB: movs [[CARRY_HI:[a-z0-9]+|lr]], #0
|
|
|
|
; CHECK-THUMB-LE: cmp [[REG1]], r2
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG2]], r3
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movls.w [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG2]], r3
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG1]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movle [[CARRY_HI]], #1
|
|
|
|
; CHECK-THUMB: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK-THUMB: mov [[OUT_HI:[a-z0-9]+]], r3
|
|
|
|
; CHECK-THUMB: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK-THUMB: mov [[OUT_LO:[a-z0-9]+]], r2
|
|
|
|
; CHECK-THUMB: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK-THUMB: movne [[OUT_LO]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2012-11-29 22:41:25 +08:00
|
|
|
%r = atomicrmw min i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test11(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test11:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: mov [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[CARRY_HI:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[OUT_HI:[a-z0-9]+]], r2
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG1]], r1
|
|
|
|
; CHECK-BE: cmp [[REG2]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwls [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG2]], r2
|
|
|
|
; CHECK-BE: cmp [[REG1]], r1
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwls [[CARRY_HI]], #1
|
|
|
|
; CHECK: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK: mov [[OUT_LO:[a-z0-9]+]], r1
|
|
|
|
; CHECK: movne [[OUT_LO]], [[REG1]]
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test11:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: mov.w [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK-THUMB: movs [[CARRY_HI:[a-z0-9]+]], #0
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG1]], r2
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG2]], r3
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movls.w [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG2]], r3
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG1]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movls [[CARRY_HI]], #1
|
|
|
|
; CHECK-THUMB: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK-THUMB: mov [[OUT_HI:[a-z0-9]+]], r3
|
|
|
|
; CHECK-THUMB: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK-THUMB: mov [[OUT_LO:[a-z0-9]+]], r2
|
|
|
|
; CHECK-THUMB: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK-THUMB: movne [[OUT_LO]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2012-11-29 22:41:25 +08:00
|
|
|
%r = atomicrmw umin i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test12(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test12:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: mov [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[CARRY_HI:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[OUT_HI:[a-z0-9]+]], r2
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG1]], r1
|
|
|
|
; CHECK-BE: cmp [[REG2]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwhi [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG2]], r2
|
|
|
|
; CHECK-BE: cmp [[REG1]], r1
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwgt [[CARRY_HI]], #1
|
|
|
|
; CHECK: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK: mov [[OUT_LO:[a-z0-9]+]], r1
|
|
|
|
; CHECK: movne [[OUT_LO]], [[REG1]]
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test12:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: mov.w [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK-THUMB: movs [[CARRY_HI:[a-z0-9]+]], #0
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG1]], r2
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG2]], r3
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movhi.w [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG2]], r3
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG1]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movgt [[CARRY_HI]], #1
|
|
|
|
; CHECK-THUMB: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK-THUMB: mov [[OUT_HI:[a-z0-9]+]], r3
|
|
|
|
; CHECK-THUMB: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK-THUMB: mov [[OUT_LO:[a-z0-9]+]], r2
|
|
|
|
; CHECK-THUMB: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK-THUMB: movne [[OUT_LO]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2012-11-29 22:41:25 +08:00
|
|
|
%r = atomicrmw max i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test13(i64* %ptr, i64 %val) {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test13:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: ldrexd [[REG1:(r[0-9]?[02468])]], [[REG2:(r[0-9]?[13579])]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: mov [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[CARRY_HI:[a-z0-9]+]], #0
|
|
|
|
; CHECK: mov [[OUT_HI:[a-z0-9]+]], r2
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG1]], r1
|
|
|
|
; CHECK-BE: cmp [[REG2]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwhi [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-LE: cmp [[REG2]], r2
|
|
|
|
; CHECK-BE: cmp [[REG1]], r1
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK: movwhi [[CARRY_HI]], #1
|
|
|
|
; CHECK: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK: mov [[OUT_LO:[a-z0-9]+]], r1
|
|
|
|
; CHECK: movne [[OUT_LO]], [[REG1]]
|
2012-11-29 22:41:25 +08:00
|
|
|
; CHECK: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK: cmp
|
|
|
|
; CHECK: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-THUMB-LABEL: test13:
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: ldrexd [[REG1:[a-z0-9]+]], [[REG2:[a-z0-9]+]]
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: mov.w [[CARRY_LO:[a-z0-9]+]], #0
|
|
|
|
; CHECK-THUMB: movs [[CARRY_HI:[a-z0-9]+]], #0
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG1]], r2
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG2]], r3
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movhi.w [[CARRY_LO]], #1
|
2014-05-08 22:06:24 +08:00
|
|
|
; CHECK-THUMB-LE: cmp [[REG2]], r3
|
|
|
|
; CHECK-THUMB-BE: cmp [[REG1]], r2
|
2014-04-03 19:44:58 +08:00
|
|
|
; CHECK-THUMB: movhi [[CARRY_HI]], #1
|
|
|
|
; CHECK-THUMB: moveq [[CARRY_HI]], [[CARRY_LO]]
|
|
|
|
; CHECK-THUMB: mov [[OUT_HI:[a-z0-9]+]], r3
|
|
|
|
; CHECK-THUMB: cmp [[CARRY_HI]], #0
|
|
|
|
; CHECK-THUMB: mov [[OUT_LO:[a-z0-9]+]], r2
|
|
|
|
; CHECK-THUMB: movne [[OUT_HI]], [[REG2]]
|
|
|
|
; CHECK-THUMB: movne [[OUT_LO]], [[REG1]]
|
2013-01-29 17:06:13 +08:00
|
|
|
; CHECK-THUMB: strexd {{[a-z0-9]+}}, [[REG3]], [[REG4]]
|
|
|
|
; CHECK-THUMB: cmp
|
|
|
|
; CHECK-THUMB: bne
|
2013-07-03 17:20:36 +08:00
|
|
|
; CHECK-THUMB: dmb {{ish$}}
|
2012-11-29 22:41:25 +08:00
|
|
|
%r = atomicrmw umax i64* %ptr, i64 %val seq_cst
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|