Skip to content

Commit be8fd86

Browse files
committed
Revert "[GlobalISel] Fix the infinite loop issue in commute_int_constant_to_rhs"
This reverts commit 1f01c58 because combine-commute-int-const-lhs.mir test failed in multiple builders. https://lab.llvm.org/buildbot/#/builders/124/builds/10375 https://luci-milo.appspot.com/ui/p/fuchsia/builders/prod/clang-linux-x64/b8751607530180046481/overview
1 parent dcc45fa commit be8fd86

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,15 +6273,14 @@ bool CombinerHelper::matchShiftsTooBig(MachineInstr &MI) {
62736273
bool CombinerHelper::matchCommuteConstantToRHS(MachineInstr &MI) {
62746274
Register LHS = MI.getOperand(1).getReg();
62756275
Register RHS = MI.getOperand(2).getReg();
6276-
if (!getIConstantVRegVal(LHS, MRI)) {
6277-
// Skip commuting if LHS is not a constant. But, LHS may be a
6278-
// G_CONSTANT_FOLD_BARRIER. If so we commute as long as we don't already
6279-
// have a constant on the RHS.
6280-
if (MRI.getVRegDef(LHS)->getOpcode() !=
6281-
TargetOpcode::G_CONSTANT_FOLD_BARRIER)
6282-
return false;
6283-
}
6284-
// Commute as long as RHS is not a constant or G_CONSTANT_FOLD_BARRIER.
6276+
auto *LHSDef = MRI.getVRegDef(LHS);
6277+
if (getIConstantVRegVal(LHS, MRI).has_value())
6278+
return true;
6279+
6280+
// LHS may be a G_CONSTANT_FOLD_BARRIER. If so we commute
6281+
// as long as we don't already have a constant on the RHS.
6282+
if (LHSDef->getOpcode() != TargetOpcode::G_CONSTANT_FOLD_BARRIER)
6283+
return false;
62856284
return MRI.getVRegDef(RHS)->getOpcode() !=
62866285
TargetOpcode::G_CONSTANT_FOLD_BARRIER &&
62876286
!getIConstantVRegVal(RHS, MRI);

llvm/test/CodeGen/AArch64/GlobalISel/combine-commute-int-const-lhs.mir

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)