[llvm] [AArch64][GISel] Recover ADDHN from OR comparison masks (PR #213925)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 08:17:07 PDT 2026
================
@@ -385,6 +385,47 @@ void applyOrToBSP(MachineInstr &MI, MachineRegisterInfo &MRI,
MI.eraseFromParent();
}
+/// Match G_TRUNC (G_OR X, Y) => G_ADDHN X, Y when both inputs are sign
+/// extended from the result element type. The high half of the addition then
+/// equals the truncation of the OR.
+bool matchTruncOrToADDHN(MachineInstr &MI, MachineRegisterInfo &MRI,
+ GISelValueTracking *VT) {
+ assert(MI.getOpcode() == TargetOpcode::G_TRUNC && VT);
+
+ Register Dst = MI.getOperand(0).getReg();
+ Register Or = MI.getOperand(1).getReg();
+ MachineInstr *OrMI = getOpcodeDef(TargetOpcode::G_OR, Or, MRI);
----------------
davemgreen wrote:
You could pass the regs through to this function, to avoid the need to re-discover the Or MI.
https://github.com/llvm/llvm-project/pull/213925
More information about the llvm-commits
mailing list