Skip to content

Commit

Permalink
[X86] Merge (near) duplicate scalar non-temporal store code. NFCI.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286595 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
RKSimon committed Nov 11, 2016
1 parent 57621b5 commit f3e8e4e
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7514,36 +7514,26 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
}

case X86::BI__builtin_ia32_movnti:
case X86::BI__builtin_ia32_movnti64: {
llvm::MDNode *Node = llvm::MDNode::get(
getLLVMContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1)));

// Convert the type of the pointer to a pointer to the stored type.
Value *BC = Builder.CreateBitCast(Ops[0],
llvm::PointerType::getUnqual(Ops[1]->getType()),
"cast");
StoreInst *SI = Builder.CreateDefaultAlignedStore(Ops[1], BC);
SI->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);

// No alignment for scalar intrinsic store.
SI->setAlignment(1);
return SI;
}
case X86::BI__builtin_ia32_movnti64:
case X86::BI__builtin_ia32_movntsd:
case X86::BI__builtin_ia32_movntss: {
llvm::MDNode *Node = llvm::MDNode::get(
getLLVMContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1)));

Value *Ptr = Ops[0];
Value *Src = Ops[1];

// Extract the 0'th element of the source vector.
Value *Scl = Builder.CreateExtractElement(Ops[1], (uint64_t)0, "extract");
if (BuiltinID == X86::BI__builtin_ia32_movntsd ||
BuiltinID == X86::BI__builtin_ia32_movntss)
Src = Builder.CreateExtractElement(Src, (uint64_t)0, "extract");

// Convert the type of the pointer to a pointer to the stored type.
Value *BC = Builder.CreateBitCast(Ops[0],
llvm::PointerType::getUnqual(Scl->getType()),
"cast");
Value *BC = Builder.CreateBitCast(
Ptr, llvm::PointerType::getUnqual(Src->getType()), "cast");

// Unaligned nontemporal store of the scalar value.
StoreInst *SI = Builder.CreateDefaultAlignedStore(Scl, BC);
StoreInst *SI = Builder.CreateDefaultAlignedStore(Src, BC);
SI->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
SI->setAlignment(1);
return SI;
Expand Down

0 comments on commit f3e8e4e

Please sign in to comment.