From 78865050620e6b6b90be7e868ffe5d5e67159856 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 13 Sep 2022 14:22:58 -0400 Subject: [PATCH] llvm-reduce: Add undef to new subregister IMPLICIT_DEFs This avoids a verifier error from the other unused lanes when LiveIntervals is used. --- llvm/test/tools/llvm-reduce/mir/subreg-def0.mir | 2 +- llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/test/tools/llvm-reduce/mir/subreg-def0.mir b/llvm/test/tools/llvm-reduce/mir/subreg-def0.mir index 590ea61..dd3ecd7 100644 --- a/llvm/test/tools/llvm-reduce/mir/subreg-def0.mir +++ b/llvm/test/tools/llvm-reduce/mir/subreg-def0.mir @@ -5,7 +5,7 @@ # CHECK-INTERESTINGNESS: V_ADD_U32 # RESULT: undef %{{[0-9]+}}.sub1:vreg_64 = IMPLICIT_DEF -# RESULT-NEXT: %{{[0-9]+}}.sub0:vreg_64 = IMPLICIT_DEF +# RESULT-NEXT: undef %{{[0-9]+}}.sub0:vreg_64 = IMPLICIT_DEF # RESULT-NEXT: %1:vgpr_32 = V_ADD_U32_e32 %{{[0-9]+}}.sub0, %{{[0-9]+}}.sub1, implicit $exec # RESULT-NEXT: S_ENDPGM 0, implicit %1 diff --git a/llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp b/llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp index c87d5eb..9b2a475 100644 --- a/llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp @@ -128,8 +128,13 @@ static void extractInstrFromFunction(Oracle &O, MachineFunction &MF) { bool IsGeneric = MRI->getRegClassOrNull(Reg) == nullptr; unsigned ImpDef = IsGeneric ? TargetOpcode::G_IMPLICIT_DEF : TargetOpcode::IMPLICIT_DEF; + + unsigned State = getRegState(MO); + if (MO.getSubReg()) + State |= RegState::Undef; + BuildMI(*EntryMBB, EntryInsPt, DebugLoc(), TII->get(ImpDef)) - .addReg(NewReg, getRegState(MO), MO.getSubReg()); + .addReg(NewReg, State, MO.getSubReg()); } // Update all uses. -- 2.7.4