Skip to content

Commit eb76982

Browse files
author
Kai Luo
authored
[PowerPC][EarlyIfConversion] Do not insert isel if subtarget doesn't support isel (#72211)
Some subtargets of PPC don't support `isel` instruction, early-ifcvt should not insert this instruction.
1 parent 0f84068 commit eb76982

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,9 @@ bool PPCInstrInfo::canInsertSelect(const MachineBasicBlock &MBB,
15301530
Register DstReg, Register TrueReg,
15311531
Register FalseReg, int &CondCycles,
15321532
int &TrueCycles, int &FalseCycles) const {
1533+
if (!Subtarget.hasISEL())
1534+
return false;
1535+
15331536
if (Cond.size() != 2)
15341537
return false;
15351538

llvm/test/CodeGen/PowerPC/early-ifcvt-no-isel.mir

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@ machineFunctionInfo: {}
3838
body: |
3939
; CHECK-LABEL: name: foo
4040
; CHECK: bb.0.entry:
41+
; CHECK-NEXT: successors: %bb.1, %bb.2
4142
; CHECK-NEXT: liveins: $x3
4243
; CHECK-NEXT: {{ $}}
4344
; CHECK-NEXT: [[COPY:%[0-9]+]]:g8rc_and_g8rc_nox0 = COPY $x3
4445
; CHECK-NEXT: [[LWZ:%[0-9]+]]:gprc_and_gprc_nor0 = LWZ 0, [[COPY]] :: (load (s32) from %ir.dummy)
4546
; CHECK-NEXT: [[ADDI:%[0-9]+]]:gprc_and_gprc_nor0 = nsw ADDI [[LWZ]], 1
4647
; CHECK-NEXT: [[CMPWI:%[0-9]+]]:crrc = CMPWI [[LWZ]], 750
4748
; CHECK-NEXT: [[LI:%[0-9]+]]:gprc_and_gprc_nor0 = LI 1
48-
; CHECK-NEXT: [[ISEL:%[0-9]+]]:gprc = ISEL [[ADDI]], [[LI]], [[CMPWI]].sub_lt
49-
; CHECK-NEXT: STW killed [[ISEL]], 0, [[COPY]] :: (store (s32) into %ir.dummy)
49+
; CHECK-NEXT: BCC 12, [[CMPWI]], %bb.2
50+
; CHECK-NEXT: {{ $}}
51+
; CHECK-NEXT: bb.1.entry:
52+
; CHECK-NEXT: {{ $}}
53+
; CHECK-NEXT: bb.2.entry:
54+
; CHECK-NEXT: [[PHI:%[0-9]+]]:gprc = PHI [[LI]], %bb.1, [[ADDI]], %bb.0
55+
; CHECK-NEXT: STW killed [[PHI]], 0, [[COPY]] :: (store (s32) into %ir.dummy)
5056
; CHECK-NEXT: [[LI8_:%[0-9]+]]:g8rc = LI8 0
5157
; CHECK-NEXT: $x3 = COPY [[LI8_]]
5258
; CHECK-NEXT: BLR8 implicit $lr8, implicit $rm, implicit $x3

0 commit comments

Comments
 (0)