Skip to content

Commit abc979a

Browse files
committed
[Z80] Avoid redundant boolean materialization in branch conditions
1 parent 253c93b commit abc979a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

llvm/lib/Target/Z80/GISel/Z80InstructionSelector.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,8 +2717,17 @@ Z80InstructionSelector::foldSetCC(MachineInstr &I, MachineIRBuilder &MIB,
27172717
for (MachineBasicBlock::iterator II = I, EI = MIB.getInsertPt(); II != EI; ++II) {
27182718
if (II == MBB.end())
27192719
return Z80::COND_INVALID;
2720+
2721+
if (II->isDebugInstr())
2722+
continue;
2723+
2724+
if (II->modifiesRegister(Z80::F, &TRI))
2725+
return Z80::COND_INVALID;
2726+
27202727
switch (II->getOpcode()) {
27212728
case Z80::SetCC:
2729+
case TargetOpcode::COPY:
2730+
case TargetOpcode::G_TRUNC:
27222731
continue;
27232732
}
27242733
return Z80::COND_INVALID;

llvm/lib/Target/Z80/Z80Combine.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ def Z80PreLegalizerCombiner
6666

6767
def Z80PostLegalizerCombiner
6868
: GICombiner<"Z80PostLegalizerCombinerImpl", [
69-
combine_identity, narrow_op, simplify_known_const, trunc_ext_fold,
70-
unmerge_zext_to_zext,
69+
combine_identity, narrow_op, select_same_val, simplify_known_const,
70+
trunc_ext_fold, unmerge_zext_to_zext,
7171
]>;

0 commit comments

Comments
 (0)