Skip to content

Commit 94a77eb

Browse files
committed
[AArch64][GlobalISel] Guard against no operands in matchHoistLogicOpWithSameOpcodeHands
In case both LeftHandInst and RightHandInst are IMPLICIT_DEF with no input operands, this patch protects against the post-legalizer-combiner matchHoistLogicOpWithSameOpcodeHands with no operands. The prelegalizercombiner-hoist-same-hands.mir test was cleaned up a little in the process, and has a post-legalizer run line added so that the implicit_def do not get folded awwy.
1 parent 217e0f3 commit 94a77eb

File tree

2 files changed

+293
-232
lines changed

2 files changed

+293
-232
lines changed

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,9 @@ bool CombinerHelper::matchHoistLogicOpWithSameOpcodeHands(
30953095
unsigned HandOpcode = LeftHandInst->getOpcode();
30963096
if (HandOpcode != RightHandInst->getOpcode())
30973097
return false;
3098-
if (!LeftHandInst->getOperand(1).isReg() ||
3098+
if (LeftHandInst->getNumOperands() < 2 ||
3099+
!LeftHandInst->getOperand(1).isReg() ||
3100+
RightHandInst->getNumOperands() < 2 ||
30993101
!RightHandInst->getOperand(1).isReg())
31003102
return false;
31013103

0 commit comments

Comments
 (0)