[all-commits] [llvm/llvm-project] b52029: [NFC][SimplifyCFG] fold-branch-to-common-dest: add...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Tue Dec 1 04:20:06 PST 2020


  Branch: refs/heads/temp-test-main
  Home:   https://github.com/llvm/llvm-project
  Commit: b52029224c183d33c5a3bd9b14f3375e25f15fa5
      https://github.com/llvm/llvm-project/commit/b52029224c183d33c5a3bd9b14f3375e25f15fa5
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

  Log Message:
  -----------
  [NFC][SimplifyCFG] fold-branch-to-common-dest: add tests with cond of br not being the last op


  Commit: 15f8060f6f2388d503fcd400e1226c69554c1924
      https://github.com/llvm/llvm-project/commit/15f8060f6f2388d503fcd400e1226c69554c1924
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

  Log Message:
  -----------
  [SimplifyCFG] FoldBranchToCommonDest: don't require that cmp of br is last instruction

There is no correctness need for that, and since we allow live-out
uses, this could theoretically happen, because currently nothing
will move the cond to right before the branch in those tests.
But regardless, lifting that restriction even makes the transform
easier to understand.

This makes the transform happen in 81 more cases (+0.55%)
)


  Commit: 0e11f3ade5eaa5ef7fe87014edd3abc708807aba
      https://github.com/llvm/llvm-project/commit/0e11f3ade5eaa5ef7fe87014edd3abc708807aba
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/test/Transforms/InstCombine/sext.ll

  Log Message:
  -----------
  [NFC][InstCombine] Autogenerate sext.ll test checklines


  Commit: 799626b1117c4cecba7c2c67c1ed7c5f1856fb24
      https://github.com/llvm/llvm-project/commit/799626b1117c4cecba7c2c67c1ed7c5f1856fb24
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/test/Transforms/InstCombine/sext.ll

  Log Message:
  -----------
  [NFC][InstCombine] Add PR48343 miscompiled testcase


  Commit: 8e29e20e0d84719e1ad24f28be458db1d9c858db
      https://github.com/llvm/llvm-project/commit/8e29e20e0d84719e1ad24f28be458db1d9c858db
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/test/Transforms/InstCombine/sext.ll

  Log Message:
  -----------
  [InstCombine] Evaluate new shift amount for sext(ashr(shl(trunc()))) fold in wide type (PR48343)

It is not correct to compute that new shift amount in it's narrow type
and only then extend it into the wide type:

----------------------------------------
Optimization: PR48343 good
Precondition: (width(%X) == width(%r))
  %o0 = trunc %X
  %o1 = shl %o0, %Y
  %o2 = ashr %o1, %Y
  %r = sext %o2
=>
  %n0 = sext %Y
  %n1 = sub width(%o0), %n0
  %n2 = sub width(%X), %n1
  %n3 = shl %X, %n2
  %r = ashr %n3, %n2

Done: 2016
Optimization is correct!

----------------------------------------
Optimization: PR48343 bad
Precondition: (width(%X) == width(%r))
  %o0 = trunc %X
  %o1 = shl %o0, %Y
  %o2 = ashr %o1, %Y
  %r = sext %o2
=>
  %n0 = sub width(%o0), %Y
  %n1 = sub width(%X), %n0
  %n2 = sext %n1
  %n3 = shl %X, %n2
  %r = ashr %n3, %n2

Done: 1
ERROR: Domain of definedness of Target is smaller than Source's for i9 %r

Example:
%X i9 = 0x000 (0)
%Y i4 = 0x3 (3)
%o0 i4 = 0x0 (0)
%o1 i4 = 0x0 (0)
%o2 i4 = 0x0 (0)
%n0 i4 = 0x1 (1)
%n1 i4 = 0x8 (8, -8)
%n2 i9 = 0x1F8 (504, -8)
%n3 i9 = 0x000 (0)
Source value: 0x000 (0)
Target value: undef


I.e. we should be computing it in the wide type from the beginning.

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


  Commit: 075faa8d40b113d19c3643b3bf2cc74f146612b0
      https://github.com/llvm/llvm-project/commit/075faa8d40b113d19c3643b3bf2cc74f146612b0
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/test/Transforms/InstCombine/sext.ll

  Log Message:
  -----------
  [NFC][InstCombine] Improve vector undef test coverage for sext(ashr(shl(trunc()))) fold


  Commit: aa1aa135097ecfab6d9917a435142030eff0a226
      https://github.com/llvm/llvm-project/commit/aa1aa135097ecfab6d9917a435142030eff0a226
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/test/Transforms/InstCombine/sext.ll

  Log Message:
  -----------
  [InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold

If the shift amount was undef for some lane, the shift amount in opposite
shift is irrelevant for that lane, and the new shift amount for that lane
can be undef.


Compare: https://github.com/llvm/llvm-project/compare/6dbd0d36a172...aa1aa135097e


More information about the All-commits mailing list