[llvm-commits] [llvm] r85044 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h
Evan Cheng
evan.cheng at apple.com
Sun Oct 25 00:47:08 PDT 2009
Author: evancheng
Date: Sun Oct 25 02:47:07 2009
New Revision: 85044
URL: http://llvm.org/viewvc/llvm-project?rev=85044&view=rev
Log:
Add isIdentityCopy to check for identity copy (or extract_subreg, etc.)
Modified:
llvm/trunk/include/llvm/Target/TargetInstrInfo.h
Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=85044&r1=85043&r2=85044&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Sun Oct 25 02:47:07 2009
@@ -145,20 +145,30 @@
/// isIdentityCopy - Return true if the instruction is a copy (or
/// extract_subreg, insert_subreg, subreg_to_reg) where the source and
/// destination registers are the same.
- bool isIdentityCopy(const MachineInstr &MI) const {
- unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
+ bool isIdentityCopy(const MachineInstr &MI,
+ unsigned &SrcReg, unsigned &DstReg,
+ unsigned &SrcSubIdx, unsigned &DstSubIdx) const {
if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
SrcReg == DstReg)
return true;
- if (MI.getOpcode() == TargetInstrInfo::EXTRACT_SUBREG &&
- MI.getOperand(0).getReg() == MI.getOperand(1).getReg())
- return true;
+ if (MI.getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) {
+ DstReg = MI.getOperand(0).getReg();
+ DstSubIdx = MI.getOperand(0).getSubReg();
+ SrcReg = MI.getOperand(1).getReg();
+ SrcSubIdx = MI.getOperand(1).getSubReg();
+ return DstReg == SrcReg;
+ }
+
+ if (MI.getOpcode() == TargetInstrInfo::INSERT_SUBREG ||
+ MI.getOpcode() == TargetInstrInfo::SUBREG_TO_REG) {
+ DstReg = MI.getOperand(0).getReg();
+ DstSubIdx = MI.getOperand(0).getSubReg();
+ SrcReg = MI.getOperand(2).getReg();
+ SrcSubIdx = MI.getOperand(2).getSubReg();
+ return DstReg == SrcReg;
+ }
- if ((MI.getOpcode() == TargetInstrInfo::INSERT_SUBREG ||
- MI.getOpcode() == TargetInstrInfo::SUBREG_TO_REG) &&
- MI.getOperand(0).getReg() == MI.getOperand(2).getReg())
- return true;
return false;
}
More information about the llvm-commits
mailing list