[llvm] r266828 - ARM: fix assertion failure on -O0 cmpxchg.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 15:25:03 PDT 2016
Author: tnorthover
Date: Tue Apr 19 17:25:02 2016
New Revision: 266828
URL: http://llvm.org/viewvc/llvm-project?rev=266828&view=rev
Log:
ARM: fix assertion failure on -O0 cmpxchg.
Because lowering of CMP_SWAP_64 occurs during type legalization, there can be
i64 types produced by more than just a BUILD_PAIR or similar. My initial tests
used just incoming function args.
Modified:
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=266828&r1=266827&r2=266828&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Apr 19 17:25:02 2016
@@ -6971,13 +6971,17 @@ static void ReplaceREADCYCLECOUNTER(SDNo
Results.push_back(Cycles32.getValue(1));
}
-static SDValue createGPRPairNode(SelectionDAG &DAG, SDValue V0, SDValue V1) {
- SDLoc dl(V0.getNode());
+static SDValue createGPRPairNode(SelectionDAG &DAG, SDValue V) {
+ SDLoc dl(V.getNode());
+ SDValue VLo = DAG.getAnyExtOrTrunc(V, dl, MVT::i32);
+ SDValue VHi = DAG.getAnyExtOrTrunc(
+ DAG.getNode(ISD::SRL, dl, MVT::i64, V, DAG.getConstant(32, dl, MVT::i32)),
+ dl, MVT::i32);
SDValue RegClass =
DAG.getTargetConstant(ARM::GPRPairRegClassID, dl, MVT::i32);
SDValue SubReg0 = DAG.getTargetConstant(ARM::gsub_0, dl, MVT::i32);
SDValue SubReg1 = DAG.getTargetConstant(ARM::gsub_1, dl, MVT::i32);
- const SDValue Ops[] = { RegClass, V0, SubReg0, V1, SubReg1 };
+ const SDValue Ops[] = { RegClass, VLo, SubReg0, VHi, SubReg1 };
return SDValue(
DAG.getMachineNode(TargetOpcode::REG_SEQUENCE, dl, MVT::Untyped, Ops), 0);
}
@@ -6988,10 +6992,8 @@ static void ReplaceCMP_SWAP_64Results(SD
assert(N->getValueType(0) == MVT::i64 &&
"AtomicCmpSwap on types less than 64 should be legal");
SDValue Ops[] = {N->getOperand(1),
- createGPRPairNode(DAG, N->getOperand(2)->getOperand(0),
- N->getOperand(2)->getOperand(1)),
- createGPRPairNode(DAG, N->getOperand(3)->getOperand(0),
- N->getOperand(3)->getOperand(1)),
+ createGPRPairNode(DAG, N->getOperand(2)),
+ createGPRPairNode(DAG, N->getOperand(3)),
N->getOperand(0)};
SDNode *CmpSwap = DAG.getMachineNode(
ARM::CMP_SWAP_64, SDLoc(N),
Modified: llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll?rev=266828&r1=266827&r2=266828&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll Tue Apr 19 17:25:02 2016
@@ -79,3 +79,24 @@ define { i64, i1 } @test_cmpxchg_64(i64*
%res = cmpxchg i64* %addr, i64 %desired, i64 %new seq_cst monotonic
ret { i64, i1 } %res
}
+
+define { i64, i1 } @test_nontrivial_args(i64* %addr, i64 %desired, i64 %new) {
+; CHECK-LABEL: test_nontrivial_args:
+; CHECK: dmb ish
+; CHECK-NOT: uxt
+; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]:
+; CHECK: ldrexd [[OLDLO:r[0-9]+]], [[OLDHI:r[0-9]+]], [r0]
+; CHECK: cmp [[OLDLO]], {{r[0-9]+}}
+; CHECK: sbcs{{(\.w)?}} [[STATUS:r[0-9]+]], [[OLDHI]], {{r[0-9]+}}
+; CHECK: bne [[DONE:.LBB[0-9]+_[0-9]+]]
+; CHECK: strexd [[STATUS]], {{r[0-9]+}}, {{r[0-9]+}}, [r0]
+; CHECK: cmp{{(\.w)?}} [[STATUS]], #0
+; CHECK: bne [[RETRY]]
+; CHECK: [[DONE]]:
+; CHECK: dmb ish
+
+ %desired1 = add i64 %desired, 1
+ %new1 = add i64 %new, 1
+ %res = cmpxchg i64* %addr, i64 %desired1, i64 %new1 seq_cst seq_cst
+ ret { i64, i1 } %res
+}
More information about the llvm-commits
mailing list