Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / Target / AArch64 / AArch64SelectionDAGInfo.cpp
blob953d7387f2e05cf20a8b746324ae29533e9a3634
1 //===-- AArch64SelectionDAGInfo.cpp - AArch64 SelectionDAG Info -----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the AArch64SelectionDAGInfo class.
11 //===----------------------------------------------------------------------===//
13 #include "AArch64TargetMachine.h"
14 using namespace llvm;
16 #define DEBUG_TYPE "aarch64-selectiondag-info"
18 SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
19 SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
20 SDValue Size, unsigned Align, bool isVolatile,
21 MachinePointerInfo DstPtrInfo) const {
22 // Check to see if there is a specialized entry-point for memory zeroing.
23 ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
24 ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size);
25 const AArch64Subtarget &STI =
26 DAG.getMachineFunction().getSubtarget<AArch64Subtarget>();
27 const char *bzeroName = (V && V->isNullValue())
28 ? DAG.getTargetLoweringInfo().getLibcallName(RTLIB::BZERO) : nullptr;
29 // For small size (< 256), it is not beneficial to use bzero
30 // instead of memset.
31 if (bzeroName && (!SizeValue || SizeValue->getZExtValue() > 256)) {
32 const AArch64TargetLowering &TLI = *STI.getTargetLowering();
34 EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout());
35 Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
36 TargetLowering::ArgListTy Args;
37 TargetLowering::ArgListEntry Entry;
38 Entry.Node = Dst;
39 Entry.Ty = IntPtrTy;
40 Args.push_back(Entry);
41 Entry.Node = Size;
42 Args.push_back(Entry);
43 TargetLowering::CallLoweringInfo CLI(DAG);
44 CLI.setDebugLoc(dl)
45 .setChain(Chain)
46 .setLibCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
47 DAG.getExternalSymbol(bzeroName, IntPtr),
48 std::move(Args))
49 .setDiscardResult();
50 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
51 return CallResult.second;
53 return SDValue();
55 bool AArch64SelectionDAGInfo::generateFMAsInMachineCombiner(
56 CodeGenOpt::Level OptLevel) const {
57 return OptLevel >= CodeGenOpt::Aggressive;