Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions llvm/lib/CodeGen/MachineVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,9 +1615,8 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
case TargetOpcode::G_UCMP: {
LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
LLT SrcTy = MRI->getType(MI->getOperand(1).getReg());
LLT SrcTy2 = MRI->getType(MI->getOperand(2).getReg());

if (SrcTy.isPointerOrPointerVector() || SrcTy2.isPointerOrPointerVector()) {
if (SrcTy.isPointerOrPointerVector()) {
report("Generic scmp/ucmp does not support pointers as operands", MI);
break;
}
Expand All @@ -1627,18 +1626,18 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
break;
}

if (DstTy.getScalarSizeInBits() < 2) {
report("Result type must be at least 2 bits wide", MI);
break;
}

if ((DstTy.isVector() != SrcTy.isVector()) ||
(DstTy.isVector() &&
DstTy.getElementCount() != SrcTy.getElementCount())) {
report("Generic vector scmp/ucmp must preserve number of lanes", MI);
break;
}

if (SrcTy != SrcTy2) {
report("Generic scmp/ucmp must have same input types", MI);
break;
}

break;
}
case TargetOpcode::G_EXTRACT: {
Expand Down
10 changes: 7 additions & 3 deletions llvm/test/MachineVerifier/test_uscmp.mir
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ body: |
%23:_(<2 x s32>) = G_IMPLICIT_DEF
%24:_(<2 x s32>) = G_IMPLICIT_DEF
; CHECK: Generic vector scmp/ucmp must preserve number of lanes
%5:_(s1) = G_UCMP %23, %24
%5:_(s2) = G_UCMP %23, %24

%15:_(s32) = G_CONSTANT i32 0
%16:_(s64) = G_CONSTANT i64 2
; CHECK: Generic scmp/ucmp must have same input types
%17:_(s1) = G_SCMP %15, %16
; CHECK: Type mismatch in generic instruction
%17:_(s2) = G_SCMP %15, %16

%18:_(s32) = G_CONSTANT i32 0
%19:_(s32) = G_CONSTANT i32 2
; CHECK: Result type must be at least 2 bits wide
%20:_(s1) = G_SCMP %18, %19


...
Loading