[all-commits] [llvm/llvm-project] 5d1f27: GlobalISel: neg (and x, 1) --> SIGN_EXTEND_INREG...

Matthias Braun via All-commits all-commits at lists.llvm.org
Mon Mar 31 16:07:12 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d1f27f349f5b63646c714e8c26cc5716a4b5abc
      https://github.com/llvm/llvm-project/commit/5d1f27f349f5b63646c714e8c26cc5716a4b5abc
  Author: Matthias Braun <matze at braunis.de>
  Date:   2025-03-31 (Mon, 31 Mar 2025)

  Changed paths:
    M llvm/include/llvm/Target/GlobalISel/Combine.td
    A llvm/test/CodeGen/AArch64/GlobalISel/combine-neg-and-one-to-sext-inreg.mir

  Log Message:
  -----------
  GlobalISel: neg (and x, 1)  -->  SIGN_EXTEND_INREG x, 1 (#131367)

The pattern
```LLVM
%shl = shl i32 %x, 31
%ashr = ashr i32 %shl, 31
```
would be combined to `G_EXT_INREG %x, 1` by GlobalISel. However
InstCombine normalizes this pattern to:
```LLVM
%and = and i32 %x, 1
%neg = sub i32 0, %and
```
This adds a combiner for this variant as well.



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