[all-commits] [llvm/llvm-project] bc6faf: [X86] X86LegalizerInfo - use LegalFor instead if L...

Dipesh Sharma via All-commits all-commits at lists.llvm.org
Mon Jun 23 01:50:49 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bc6faf9a020880f2902581a898e4434000d263f7
      https://github.com/llvm/llvm-project/commit/bc6faf9a020880f2902581a898e4434000d263f7
  Author: Dipesh Sharma <76941383+dipeshs809 at users.noreply.github.com>
  Date:   2025-06-23 (Mon, 23 Jun 2025)

  Changed paths:
    M llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp

  Log Message:
  -----------
  [X86] X86LegalizerInfo - use LegalFor instead if LegalIf for simple ISA/test pairs (#144675)

We have lots of `legalIf to` evaluate the legality of instructions based
on predicate's truthfulness, which should be simplified to use the
`legalFor({Types})` or `legalFor(Pred, {Types})` helpers:

closes #138259 

for eg: 

```
  getActionDefinitionsBuilder({G_ADD, G_SUB})
      .legalIf([=](const LegalityQuery &Query) -> bool {
        if (typeInSet(0, {s8, s16, s32})(Query))
          return true;
        if (Is64Bit && typeInSet(0, {s64})(Query))
          return true;
        if (HasSSE2 && typeInSet(0, {v16s8, v8s16, v4s32, v2s64})(Query))
          return true;
        if (HasAVX2 && typeInSet(0, {v32s8, v16s16, v8s32, v4s64})(Query))
          return true;
        if (HasAVX512 && typeInSet(0, {v16s32, v8s64})(Query))
          return true;
        if (HasBWI && typeInSet(0, {v64s8, v32s16})(Query))
          return true;
        return false;
      })
```
gets transformed to:

```
  getActionDefinitionsBuilder({G_ADD, G_SUB})
      .legalFor({s8, s16, s32})
      .legalFor(Is64Bit, {s64})
      .legalFor(HasSSE2, {v16s8, v8s16, v4s32, v2s64})
 --- etc ---
```

---------

Co-authored-by: Simon Pilgrim <llvm-dev at redking.me.uk>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list