llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Daniel Sanders e08d6cea34 Revert r331816 and r331820 - [globalisel] Add a combiner helpers for extending loads and use them in a pre-legalize combiner for AArch64
Reverting this to see if the clang-cmake-aarch64-global-isel and
clang-cmake-aarch64-quick bots are failing because of this commit.
We know it wasn't r331819.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331846 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 05:00:17 +00:00

42 lines
1.3 KiB
C++

//== ---lib/CodeGen/GlobalISel/GICombinerHelper.cpp --------------------- == //
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#define DEBUG_TYPE "gi-combine"
using namespace llvm;
CombinerHelper::CombinerHelper(MachineIRBuilder &B) :
Builder(B), MRI(Builder.getMF().getRegInfo()) {}
bool CombinerHelper::tryCombineCopy(MachineInstr &MI) {
if (MI.getOpcode() != TargetOpcode::COPY)
return false;
unsigned DstReg = MI.getOperand(0).getReg();
unsigned SrcReg = MI.getOperand(1).getReg();
LLT DstTy = MRI.getType(DstReg);
LLT SrcTy = MRI.getType(SrcReg);
// Simple Copy Propagation.
// a(sx) = COPY b(sx) -> Replace all uses of a with b.
if (DstTy.isValid() && SrcTy.isValid() && DstTy == SrcTy) {
MI.eraseFromParent();
MRI.replaceRegWith(DstReg, SrcReg);
return true;
}
return false;
}
bool CombinerHelper::tryCombine(MachineInstr &MI) {
return tryCombineCopy(MI);
}