[llvm] [Mips] Optimize `or (and $src1, mask0), (shl $src2, mask1)` to `ins` (PR #103017)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 20:28:09 PDT 2024
================
@@ -876,21 +876,47 @@ static SDValue performANDCombine(SDNode *N, SelectionDAG &DAG,
static SDValue performORCombine(SDNode *N, SelectionDAG &DAG,
TargetLowering::DAGCombinerInfo &DCI,
const MipsSubtarget &Subtarget) {
- // Pattern match INS.
- // $dst = or (and $src1 , mask0), (and (shl $src, pos), mask1),
- // where mask1 = (2**size - 1) << pos, mask0 = ~mask1
- // => ins $dst, $src, size, pos, $src1
if (DCI.isBeforeLegalizeOps() || !Subtarget.hasExtractInsert())
return SDValue();
SDValue And0 = N->getOperand(0), And1 = N->getOperand(1);
unsigned SMPos0, SMSize0, SMPos1, SMSize1;
ConstantSDNode *CN, *CN1;
+ uint64_t Pos = 0;
// See if Op's first operand matches (and $src1 , mask0).
if (And0.getOpcode() != ISD::AND)
return SDValue();
+ if (And0.getOpcode() == ISD::AND && And1.getOpcode() == ISD::SHL) {
----------------
yingopq wrote:
It can be exchanged. The expected optimization results should be the same. I will update the code again.
https://github.com/llvm/llvm-project/pull/103017
More information about the llvm-commits
mailing list