[all-commits] [llvm/llvm-project] 83aa0b: [NFC][InstCombine] 'subtract of one hands of selec...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Sat Jan 4 06:44:41 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 83aa0b6734da6760890012fc0ea08698741541a5
      https://github.com/llvm/llvm-project/commit/83aa0b6734da6760890012fc0ea08698741541a5
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    A llvm/test/Transforms/InstCombine/subtract-of-one-hand-of-select.ll

  Log Message:
  -----------
  [NFC][InstCombine] 'subtract of one hands of select' pattern tests (PR44426)

https://bugs.llvm.org/show_bug.cgi?id=44426


  Commit: 4d8e47ca180557e9bb872da0b8a6ad0fc515c4d3
      https://github.com/llvm/llvm-project/commit/4d8e47ca180557e9bb872da0b8a6ad0fc515c4d3
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/sub-minmax.ll
    M llvm/test/Transforms/InstCombine/subtract-of-one-hand-of-select.ll

  Log Message:
  -----------
  [InstCombine] Sink sub into hands of select if one hand becomes zero (PR44426)

This decreases use count of %Op1, makes one hand of select to be 0,
and possibly exposes further folding potential.

Name: sub (select %Cond, %Op1, %FalseVal), %Op1 -> select %Cond, 0, (sub %FalseVal, %Op1)
  %Op1 = %TrueVal
  %o = select i1 %Cond, i8 %Op1, i8 %FalseVal
  %r = sub i8 %o, %Op1
=>
  %n = sub i8 %FalseVal, %Op1
  %r = select i1 %Cond, i8 0, i8 %n

Name: sub (select %Cond, %TrueVal, %Op1), %Op1 -> select %Cond, (sub %TrueVal, %Op1), 0
  %Op1 = %FalseVal
  %o = select i1 %Cond, i8 %TrueVal, i8 %Op1
  %r = sub i8 %o, %Op1
=>
  %n = sub i8 %TrueVal, %Op1
  %r = select i1 %Cond, i8 %n, i8 0

https://rise4fun.com/Alive/avL

https://bugs.llvm.org/show_bug.cgi?id=44426


  Commit: d2b79c76be5b1613d80364888286e7ead70674eb
      https://github.com/llvm/llvm-project/commit/d2b79c76be5b1613d80364888286e7ead70674eb
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    A llvm/test/Transforms/InstCombine/subtract-from-one-hand-of-select.ll
    M llvm/test/Transforms/InstCombine/subtract-of-one-hand-of-select.ll

  Log Message:
  -----------
  [NFC][InstCombine] 'subtract from one hands of select' pattern tests (PR44426)

https://bugs.llvm.org/show_bug.cgi?id=44426


  Commit: 772ede3d5d552e0214473f247f7f98f15e596fe5
      https://github.com/llvm/llvm-project/commit/772ede3d5d552e0214473f247f7f98f15e596fe5
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/sub-minmax.ll
    M llvm/test/Transforms/InstCombine/subtract-from-one-hand-of-select.ll

  Log Message:
  -----------
  [InstCombine] Sink sub into hands of select if one hand becomes zero. Part 2 (PR44426)

This decreases use count of %Op0, makes one hand of select to be 0,
and possibly exposes further folding potential.

Name: sub %Op0, (select %Cond, %Op0, %FalseVal) -> select %Cond, 0, (sub %Op0, %FalseVal)
  %Op0 = %TrueVal
  %o = select i1 %Cond, i8 %Op0, i8 %FalseVal
  %r = sub i8 %Op0, %o
=>
  %n = sub i8 %Op0, %FalseVal
  %r = select i1 %Cond, i8 0, i8 %n

Name: sub %Op0, (select %Cond, %TrueVal, %Op0) -> select %Cond, (sub %Op0, %TrueVal), 0
  %Op0 = %FalseVal
  %o = select i1 %Cond, i8 %TrueVal, i8 %Op0
  %r = sub i8 %Op0, %o
=>
  %n = sub i8 %Op0, %TrueVal
  %r = select i1 %Cond, i8 %n, i8 0

https://rise4fun.com/Alive/aHRt

https://bugs.llvm.org/show_bug.cgi?id=44426


  Commit: 6d05bc2e3a9b54fde53aa5cbd83cc7c1d432cac1
      https://github.com/llvm/llvm-project/commit/6d05bc2e3a9b54fde53aa5cbd83cc7c1d432cac1
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

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

  Log Message:
  -----------
  [NFCI][InstCombine] Refactor 'sink negation into select if that folds one hand of select to 0' fold

I would think it's better than having two practically identical folds
next to eachother, but then generalization isn't all that pretty
due to the fact that we need to produce different `sub` each time..

This change is no-functional-changes-intended refactoring.


Compare: https://github.com/llvm/llvm-project/compare/831bfcea4782...6d05bc2e3a9b


More information about the All-commits mailing list