From 210c72c1b12e72d1d7fd69951ba40ffb1a2b0b3d Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 13 May 2019 21:01:24 +0000 Subject: [PATCH] [X86] Various type corrections to the code that creates LOCK_OR32mi8/OR32mi8Locked to the stack for idempotent atomic rmw and atomic fence. These are updates to match how isel table would emit a LOCK_OR32mi8 node. -Use i32 for the immediate zero even though only 8 bits are encoded. -Use i16 for segment register. -Use LOCK_OR32mi8 for idempotent atomic operations in 32-bit mode to match 64-bit mode. I'm not sure why OR32mi8Locked and LOCK_OR32mi8 both exist. The only difference seems to be that OR32mi8Locked is marked as UnmodeledSideEffects=1. -Emit an extra i32 result for the flags output. I don't know if the types here really matter just noticed it was inconsistent with normal behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360619 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index ef28d676fa1..65f3af3f544 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -25848,12 +25848,13 @@ static SDValue LowerATOMIC_FENCE(SDValue Op, const X86Subtarget &Subtarget, DAG.getTargetConstant(1, dl, MVT::i8), // Scale DAG.getRegister(0, MVT::i32), // Index DAG.getTargetConstant(0, dl, MVT::i32), // Disp - DAG.getRegister(0, MVT::i32), // Segment. + DAG.getRegister(0, MVT::i16), // Segment. Zero, Chain }; - SDNode *Res = DAG.getMachineNode(X86::OR32mi8Locked, dl, MVT::Other, Ops); - return SDValue(Res, 0); + SDNode *Res = DAG.getMachineNode(X86::OR32mi8Locked, dl, MVT::i32, + MVT::Other, Ops); + return SDValue(Res, 1); } // MEMBARRIER is a compiler barrier; it codegens to a no-op. @@ -26299,17 +26300,18 @@ static SDValue emitLockedStackOp(SelectionDAG &DAG, // https://shipilev.net/blog/2014/on-the-fence-with-dependencies/ if (Subtarget.is64Bit()) { - SDValue Zero = DAG.getTargetConstant(0, DL, MVT::i8); + SDValue Zero = DAG.getTargetConstant(0, DL, MVT::i32); SDValue Ops[] = { DAG.getRegister(X86::RSP, MVT::i64), // Base DAG.getTargetConstant(1, DL, MVT::i8), // Scale DAG.getRegister(0, MVT::i64), // Index DAG.getTargetConstant(0, DL, MVT::i32), // Disp - DAG.getRegister(0, MVT::i32), // Segment. + DAG.getRegister(0, MVT::i16), // Segment. Zero, Chain}; - SDNode *Res = DAG.getMachineNode(X86::LOCK_OR32mi8, DL, MVT::Other, Ops); - return SDValue(Res, 0); + SDNode *Res = DAG.getMachineNode(X86::LOCK_OR32mi8, DL, MVT::i32, + MVT::Other, Ops); + return SDValue(Res, 1); } SDValue Zero = DAG.getTargetConstant(0, DL, MVT::i32); @@ -26318,12 +26320,13 @@ static SDValue emitLockedStackOp(SelectionDAG &DAG, DAG.getTargetConstant(1, DL, MVT::i8), // Scale DAG.getRegister(0, MVT::i32), // Index DAG.getTargetConstant(0, DL, MVT::i32), // Disp - DAG.getRegister(0, MVT::i32), // Segment. + DAG.getRegister(0, MVT::i16), // Segment. Zero, Chain }; - SDNode *Res = DAG.getMachineNode(X86::OR32mi8Locked, DL, MVT::Other, Ops); - return SDValue(Res, 0); + SDNode *Res = DAG.getMachineNode(X86::LOCK_OR32mi8, DL, MVT::i32, + MVT::Other, Ops); + return SDValue(Res, 1); } static SDValue lowerAtomicArithWithLOCK(SDValue N, SelectionDAG &DAG, -- 2.11.4.GIT