[all-commits] [llvm/llvm-project] 0abde4: [InstCombine] fold sub of low-bit masked value fro...

RotateRight via All-commits all-commits at lists.llvm.org
Thu Nov 12 17:25:10 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0abde4bc9273374bbef68b2d24b0158f8fb338c2
      https://github.com/llvm/llvm-project/commit/0abde4bc9273374bbef68b2d24b0158f8fb338c2
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2020-11-12 (Thu, 12 Nov 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/sub.ll

  Log Message:
  -----------
  [InstCombine] fold sub of low-bit masked value from offset of same value

There might be some demanded/known bits way to generalize this,
but I'm not seeing it right now.

This came up as a regression when I was looking at a different
demanded bits improvement.

https://rise4fun.com/Alive/5fl

  Name: general
  Pre: ((-1 << countTrailingZeros(C1)) & C2) == 0
  %a1 = add i8 %x, C1
  %a2 = and i8 %x, C2
  %r = sub i8 %a1, %a2
  =>
  %r = and i8 %a1, ~C2

  Name: test 1
  %a1 = add i8 %x, 192
  %a2 = and i8 %x, 10
  %r = sub i8 %a1, %a2
  =>
  %r = and i8 %a1, -11

  Name: test 2
  %a1 = add i8 %x, -108
  %a2 = and i8 %x, 3
  %r = sub i8 %a1, %a2
  =>
  %r = and i8 %a1, -4




More information about the All-commits mailing list