[llvm] [GlobalISel] Combine away G_UNMERGE(G_IMPLICITDEF). (PR #119183)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 10:54:31 PST 2024
================
@@ -1069,6 +1069,17 @@ class LegalizationArtifactCombiner {
Builder.setInstrAndDebugLoc(MI);
+ if (SrcDef->getOpcode() == TargetOpcode::G_IMPLICIT_DEF) {
+ auto Undef = Builder.buildUndef(DestTy);
+ for (unsigned I = 0; I != NumDefs; ++I) {
+ Register Def = MI.getReg(I);
+ replaceRegOrBuildCopy(Def, Undef.getReg(0), MRI, Builder, UpdatedDefs,
+ Observer);
+ }
+ markInstAndDefDead(MI, *SrcDef, DeadInsts, SrcDefIdx);
+ return true;
+ }
+
----------------
aemerson wrote:
Should we add this logic to ArtifactValueFinder instead? If you add a case for G_IMPLICIT_DEF into `findValueFromDefImpl()` that just returns an impdef of the requested size you'll probably get this for free. I'm mostly wondering if doing so will also yield other codegen improvements on top of this change. If it doesn't then I'm ok with the current implementation.
https://github.com/llvm/llvm-project/pull/119183
More information about the llvm-commits
mailing list