Skip to content

Commit 2184160

Browse files
committed
Address reviewer comments
1 parent 8767571 commit 2184160

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,8 @@ class CombinerHelper {
866866
/// Combine insert vector element OOB.
867867
bool matchInsertVectorElementOOB(MachineInstr &MI, BuildFnTy &MatchInfo);
868868

869-
bool matchFreezeOfSingleMaybePoisonOperand(MachineInstr &MI, BuildFnTy &MatchInfo);
869+
bool matchFreezeOfSingleMaybePoisonOperand(MachineInstr &MI,
870+
BuildFnTy &MatchInfo);
870871

871872
private:
872873
/// Checks for legality of an indexed variant of \p LdSt.

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ def idempotent_prop : GICombineRule<
224224
// when Op0 is not guaranteed non-poison
225225
def push_freeze_to_prevent_poison_propagation : GICombineRule<
226226
(defs root:$root, build_fn_matchinfo:$matchinfo),
227-
(match (wip_match_opcode G_FREEZE):$root,
228-
[{ return Helper.matchFreezeOfSingleMaybePoisonOperand(*${root}, ${matchinfo}); }]),
227+
(match (G_FREEZE $dst, $src):$root,
228+
[{ return !isGuaranteedNotToBePoison(${src}.getReg(), MRI) && Helper.matchFreezeOfSingleMaybePoisonOperand(*${root}, ${matchinfo}); }]),
229229
(apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
230230

231231
def extending_loads : GICombineRule<

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ bool CombinerHelper::matchFreezeOfSingleMaybePoisonOperand(
242242
if (canCreateUndefOrPoison(OrigOp, MRI))
243243
return false;
244244

245-
std::optional<MachineOperand> MaybePoisonOperand = std::nullopt;
245+
std::optional<MachineOperand> MaybePoisonOperand;
246246
for (MachineOperand &Operand : OrigDef->uses()) {
247-
// Avoid working on non-register operands or physical registers.
248-
if (!Operand.isReg() || Operand.getReg().isPhysical())
247+
// Avoid working on non-register operands.
248+
if (!Operand.isReg())
249249
return false;
250250

251251
if (isGuaranteedNotToBeUndefOrPoison(Operand.getReg(), MRI))
@@ -258,15 +258,12 @@ bool CombinerHelper::matchFreezeOfSingleMaybePoisonOperand(
258258
return false;
259259
}
260260

261-
// Eliminate freeze if all operands are guaranteed non-poison
261+
// Eliminate freeze if all operands are guaranteed non-poison.
262262
if (!MaybePoisonOperand) {
263263
MatchInfo = [=](MachineIRBuilder &B) { MRI.replaceRegWith(DstOp, OrigOp); };
264264
return true;
265265
}
266266

267-
if (!MaybePoisonOperand->isReg())
268-
return false;
269-
270267
Register MaybePoisonOperandReg = MaybePoisonOperand->getReg();
271268
LLT MaybePoisonOperandRegTy = MRI.getType(MaybePoisonOperandReg);
272269

@@ -3118,7 +3115,6 @@ bool CombinerHelper::matchHoistLogicOpWithSameOpcodeHands(
31183115
MachineInstr *RightHandInst = getDefIgnoringCopies(RHSReg, MRI);
31193116
if (!LeftHandInst || !RightHandInst)
31203117
return false;
3121-
31223118
unsigned HandOpcode = LeftHandInst->getOpcode();
31233119
if (HandOpcode != RightHandInst->getOpcode())
31243120
return false;

0 commit comments

Comments
 (0)