[PATCH] D151878: [GlobalIsel][X86] Update legalization of G_ADD/G_SUB

Thorsten via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 05:53:45 PDT 2023


tschuett added a comment.

This probably does not compile, but it is my prototype for G_AND:

  // AND and PAND
  unsigned bitWidth = 64;
  auto& bitBuilder = getActionDefinitionsBuilder(G_AND);
  
  if (Subtarget.hasAVX512()) {
    bitBuilder.legalFor({/*512 bit*/v64s8, v32s16, v16s32, v8s64,
      /* 256 bit */ v32s8, v16s16, v8s32, v4s64,
      /* 128 bit */ v16s8, v8s16, v4s32, v2s64,
      /* 64 bit */ s8, s16, s32, s64});
    bitWidth = 512;
  } else if (Subtarget.hasAVX2()) {
    bitBuilder.legalFor({
      /* 256 bit */ v32s8, v16s16, v8s32, v4s64,
      /* 128 bit */ v16s8, v8s16, v4s32, v2s64,
      /* 64 bit */ s8, s16, s32, s64});
    bitWidth = 256;
  } else if (Subtarget.hasSSE2()) {
    bitBuilder.legalFor({
      /* 128 bit */ v16s8, v8s16, v4s32, v2s64,
      /* 64 bit */ s8, s16, s32, s64});
    bitWidth = 128;
  } else { // 64-bit
    bitBuilder.legalFor({/* 64 bit */ s8, s16, s32, s64});
  }
  
  bitBuilder.widenScalarToNextPow(0, /*Min=*/ 8)
    .clampScalar(0, s8, s64)
    .clampNumElements(0, s8, s64)
    .clampMaxNumElements(0, s8, bitWidth / 8)
    .clampMaxNumElements(0, s16, bitWidth / 16)
    .clampMaxNumElements(0, s32, bitWidth / 32)
    .clampMaxNumElements(0, s64, bitWidth / 64);


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151878/new/

https://reviews.llvm.org/D151878



More information about the llvm-commits mailing list