Home | History | Annotate | Download | only in SystemZ

Lines Matching refs:Compare

12 // (2) fuses compares and branches into COMPARE AND BRANCH instructions
16 #define DEBUG_TYPE "systemz-elim-compare"
33 STATISTIC(FusedComparisons, "Number of fused compare-and-branch instructions");
78 bool convertToBRCT(MachineInstr *MI, MachineInstr *Compare,
81 bool adjustCCMasksForInstr(MachineInstr *MI, MachineInstr *Compare,
83 bool optimizeCompareZero(MachineInstr *Compare,
85 bool fuseCompareAndBranch(MachineInstr *Compare,
162 // Compare compares the result of MI against zero. If MI is an addition
166 SystemZElimCompare::convertToBRCT(MachineInstr *MI, MachineInstr *Compare,
190 // MI and Compare. Make sure that there are also no references between
191 // Compare and Branch.
192 unsigned SrcReg = Compare->getOperand(0).getReg();
193 MachineBasicBlock::iterator MBBI = Compare, MBBE = Branch;
232 adjustCCMasksForInstr(MachineInstr *MI, MachineInstr *Compare,
238 // See which compare-style condition codes are available.
242 unsigned CompareFlags = Compare->getDesc().TSFlags;
296 MachineBasicBlock::iterator MBBI = MI, MBBE = Compare;
303 // Return true if Compare is a comparison against zero.
304 static bool isCompareZero(MachineInstr *Compare) {
305 switch (Compare->getOpcode()) {
312 return (Compare->getNumExplicitOperands() == 2 &&
313 Compare->getOperand(1).isImm() &&
314 Compare->getOperand(1).getImm() == 0);
318 // Try to optimize cases where comparison instruction Compare is testing
319 // a value against zero. Return true on success and if Compare should be
321 // value produced by Compare.
323 optimizeCompareZero(MachineInstr *Compare,
325 if (!isCompareZero(Compare))
329 unsigned SrcReg = Compare->getOperand(0).getReg();
330 unsigned SrcSubReg = Compare->getOperand(0).getSubReg();
331 MachineBasicBlock *MBB = Compare->getParent();
332 MachineBasicBlock::iterator MBBI = Compare, MBBE = MBB->begin();
339 // Try to remove both MI and Compare by converting a branch to BRCT(G).
341 // Compare.
342 if (!CCRefs.Use && !SrcRefs && convertToBRCT(MI, Compare, CCUsers)) {
346 // Try to eliminate Compare by reusing a CC result from MI.
348 (!CCRefs.Def && adjustCCMasksForInstr(MI, Compare, CCUsers))) {
363 // Try to fuse comparison instruction Compare into a later branch.
364 // Return true on success and if Compare is therefore redundant.
366 fuseCompareAndBranch(MachineInstr *Compare,
369 unsigned FusedOpcode = TII->getCompareAndBranch(Compare->getOpcode(),
370 Compare);
382 unsigned SrcReg = Compare->getOperand(0).getReg();
383 unsigned SrcReg2 = (Compare->getOperand(1).isReg() ?
384 Compare->getOperand(1).getReg() : 0);
385 MachineBasicBlock::iterator MBBI = Compare, MBBE = Branch;
405 // Rebuild Branch as a fused compare and branch.
408 .addOperand(Compare->getOperand(0))
409 .addOperand(Compare->getOperand(1))
415 MBBI = Compare;
431 // all CC users as we go. The subroutines can delete Compare and