[llvm] [GlobalISel][AArch64] Combine unmerge(G_EXT v, undef) to unmerge(v). (PR #65263)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 04:00:08 PDT 2023
================
@@ -1067,6 +1067,53 @@ void applyVectorSextInReg(MachineInstr &MI, MachineRegisterInfo &MRI,
Helper.lower(MI, 0, /* Unused hint type */ LLT());
}
+/// Combine <N x t>, unused = unmerge(G_EXT <2*N x t> v, undef, N)
+/// => unused, <N x t> = unmerge v
+bool matchUnmergeExtToUnmerge(MachineInstr &MI, MachineRegisterInfo &MRI,
+ Register &MatchInfo) {
+ assert(MI.getOpcode() == TargetOpcode::G_UNMERGE_VALUES);
+ if (MI.getNumDefs() != 2)
+ return false;
+ if (!MRI.use_nodbg_empty(MI.getOperand(1).getReg()))
+ return false;
+
+ LLT DstTy = MRI.getType(MI.getOperand(0).getReg());
+ if (!DstTy.isVector())
+ return false;
+
+ MachineInstr *Ext = getDefIgnoringCopies(
+ MI.getOperand(MI.getNumExplicitDefs()).getReg(), MRI);
+ if (!Ext || Ext->getOpcode() != AArch64::G_EXT)
+ return false;
+
+ Register ExtSrc1 = Ext->getOperand(1).getReg();
+ Register ExtSrc2 = Ext->getOperand(2).getReg();
+ auto LowestVal =
+ getIConstantVRegValWithLookThrough(Ext->getOperand(3).getReg(), MRI);
+ if (!LowestVal || LowestVal->Value.getZExtValue() != DstTy.getSizeInBytes())
+ return false;
+
+ MachineInstr *Undef = getDefIgnoringCopies(ExtSrc2, MRI);
----------------
aemerson wrote:
getOpcodeDef()
https://github.com/llvm/llvm-project/pull/65263
More information about the llvm-commits
mailing list