[all-commits] [llvm/llvm-project] 0c6979: [InstCombine] fold opposite shifts around an add

RotateRight via All-commits all-commits at lists.llvm.org
Thu Dec 30 09:01:46 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0c6979b2d64d97298671ba7ed44d1446c9f302cf
      https://github.com/llvm/llvm-project/commit/0c6979b2d64d97298671ba7ed44d1446c9f302cf
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-12-30 (Thu, 30 Dec 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
    M llvm/test/Transforms/InstCombine/lshr.ll
    M llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll

  Log Message:
  -----------
  [InstCombine] fold opposite shifts around an add

((X << C) + Y) >>u C --> (X + (Y >>u C)) & (-1 >>u C)

https://alive2.llvm.org/ce/z/DY9DPg

This replaces a shift with an 'and', and in the case
where the add has a constant operand, it eliminates
both shifts.

As noted in the TODO comment, we already have this fold when
the shifts are in the opposite order (and that code handles
bitwise logic ops too).

Fixes #52851




More information about the All-commits mailing list