diff options
author | Jacques Pienaar <jpienaar@google.com> | 2016-05-18 21:31:37 +0000 |
---|---|---|
committer | Jacques Pienaar <jpienaar@google.com> | 2016-05-18 21:31:37 +0000 |
commit | 314444b4cd16be2f5db9789bd96374eea90df497 (patch) | |
tree | 83009d5859bf2831698dcb3ae9fc683a9e9da7e0 /llvm/lib | |
parent | d2268a73bc8b505fa5d124e9b95e9cfe50698b14 (diff) | |
download | bcm5719-llvm-314444b4cd16be2f5db9789bd96374eea90df497.tar.gz bcm5719-llvm-314444b4cd16be2f5db9789bd96374eea90df497.zip |
[lanai] Change the way flag setting instructions are checked.
isReturn() was returning different values with and without -g which led to
different code being generated. Change isFlagSettingInstruction to query
an instruction's effect on SR instead.
llvm-svn: 269986
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp | 62 |
1 files changed, 11 insertions, 51 deletions
diff --git a/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp b/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp index 988352b0150..cd728778a65 100644 --- a/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp +++ b/llvm/lib/Target/Lanai/LanaiSetflagAluCombiner.cpp @@ -142,47 +142,8 @@ static unsigned flagSettingOpcodeVariant(unsigned OldOpcode) { } // Returns whether opcode corresponds to instruction that sets flags. -static bool isFlagSettingInstruction(unsigned Opcode) { - switch (Opcode) { - case Lanai::ADDC_F_I_HI: - case Lanai::ADDC_F_I_LO: - case Lanai::ADDC_F_R: - case Lanai::ADDC_F_R_CC: - case Lanai::ADD_F_I_HI: - case Lanai::ADD_F_I_LO: - case Lanai::ADD_F_R: - case Lanai::ADD_F_R_CC: - case Lanai::AND_F_I_HI: - case Lanai::AND_F_I_LO: - case Lanai::AND_F_R: - case Lanai::AND_F_R_CC: - case Lanai::OR_F_I_HI: - case Lanai::OR_F_I_LO: - case Lanai::OR_F_R: - case Lanai::OR_F_R_CC: - case Lanai::SFSUB_F_RI: - case Lanai::SFSUB_F_RR: - case Lanai::SA_F_I: - case Lanai::SL_F_I: - case Lanai::SHL_F_R: - case Lanai::SRA_F_R: - case Lanai::SRL_F_R: - case Lanai::SUBB_F_I_HI: - case Lanai::SUBB_F_I_LO: - case Lanai::SUBB_F_R: - case Lanai::SUBB_F_R_CC: - case Lanai::SUB_F_I_HI: - case Lanai::SUB_F_I_LO: - case Lanai::SUB_F_R: - case Lanai::SUB_F_R_CC: - case Lanai::XOR_F_I_HI: - case Lanai::XOR_F_I_LO: - case Lanai::XOR_F_R: - case Lanai::XOR_F_R_CC: - return true; - default: - return false; - } +static bool isFlagSettingInstruction(MbbIterator Instruction) { + return Instruction->killsRegister(Lanai::SR); } // Return the Conditional Code operand for a given instruction kind. For @@ -233,9 +194,13 @@ static bool isSuitableSetflag(MbbIterator Instruction, MbbIterator End) { MbbIterator SCCUserIter = Instruction; while (SCCUserIter != End) { ++SCCUserIter; + if (SCCUserIter == End) + break; + // Skip debug instructions. Debug instructions don't affect codegen. + if (SCCUserIter->isDebugValue()) + continue; // Early exit when encountering flag setting or return instruction. - if (isFlagSettingInstruction(SCCUserIter->getOpcode()) || - SCCUserIter->isReturn()) + if (isFlagSettingInstruction(SCCUserIter)) // Only return true if flags are set post the flag setting instruction // tested or a return is executed. return true; @@ -274,13 +239,11 @@ bool LanaiSetflagAluCombiner::CombineSetflagAluInBasicBlock( while (AluIter != Begin) { --AluIter; // Skip debug instructions. Debug instructions don't affect codegen. - if (AluIter->isDebugValue()) { + if (AluIter->isDebugValue()) continue; - } // Early exit when encountering flag setting instruction. - if (isFlagSettingInstruction(AluIter->getOpcode())) { + if (isFlagSettingInstruction(AluIter)) break; - } // Check that output of AluIter is equal to input of SetflagIter. if (AluIter->getNumOperands() > 1 && AluIter->getOperand(0).isReg() && (AluIter->getOperand(0).getReg() == @@ -299,14 +262,11 @@ bool LanaiSetflagAluCombiner::CombineSetflagAluInBasicBlock( } } // Erase the setflag instruction if merged. - if (Replaced) { + if (Replaced) BB->erase(SetflagIter++); - } } Modified |= Replaced; - if (SetflagIter == End) - break; if (!Replaced) ++SetflagIter; } |