[all-commits] [llvm/llvm-project] 615753: [InstCombine] ptrmask of gep for dynamic pointer a...

Jon Chesterfield via All-commits all-commits at lists.llvm.org
Thu Mar 7 09:36:50 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6157538d9e4eea135fb863b972c577f648c21641
      https://github.com/llvm/llvm-project/commit/6157538d9e4eea135fb863b972c577f648c21641
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2024-03-07 (Thu, 07 Mar 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
    M llvm/test/Transforms/InstCombine/ptrmask.ll

  Log Message:
  -----------
  [InstCombine] ptrmask of gep for dynamic pointer aligment (#80002)

Targets the dynamic realignment pattern of `(Ptr + Align - 1) & -Align;`
as implemented by gep then ptrmask.

Specifically, when the pointer already has alignment information,
dynamically realigning it to less than is already known should be a
no-op. Discovered while writing test cases for another patch.

For the zero low bits of a known aligned pointer, adding the gep index
then removing it with a mask is a no-op. Folding the ptrmask effect
entirely into the gep is the ideal result as that unblocks other
optimisations that are not aware of ptrmask.

In some other cases the gep is known to be dead and is removed without
changing the ptrmask.

In the least effective case, this transform creates a new gep with a
rounded-down index and still leaves the ptrmask unchanged. That
simplified gep is still a minor improvement, geps are cheap and ptrmask
occurs in address calculation contexts so I don't think it's worth
special casing to avoid the extra instruction.



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