[all-commits] [llvm/llvm-project] c86833: [SCEV] ScalarEvolution::createSCEV(): clarify no-w...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Sat Jun 6 03:02:43 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c868335e243262876b0db3328f79153bd2d27d00
      https://github.com/llvm/llvm-project/commit/c868335e243262876b0db3328f79153bd2d27d00
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-06-06 (Sat, 06 Jun 2020)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll

  Log Message:
  -----------
  [SCEV] ScalarEvolution::createSCEV(): clarify no-wrap flag propagation for shift by bitwidth-1

Summary:
There was this comment here previously:
```
-        // It is currently not resolved how to interpret NSW for left
-        // shift by BitWidth - 1, so we avoid applying flags in that
-        // case. Remove this check (or this comment) once the situation
-        // is resolved. See
-        // http://lists.llvm.org/pipermail/llvm-dev/2015-April/084195.html
-        // and http://reviews.llvm.org/D8890 .
```
But langref was fixed in rL286785, and the behavior is pretty obvious:
http://volta.cs.utah.edu:8080/z/MM4WZP
^ nuw can always be propagated. nsw can be propagated if
either nuw is specified, or the shift is by *less* than bitwidth-1.

This mimics similar D81189 Reassociate change, alive2 is happy about that one.

I'm not sure `NUW` isn't being printed, but that seems unrelated.

Reviewers: mkazantsev, reames, sanjoy, nlopes, craig.topper, efriedma

Reviewed By: efriedma

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81243


  Commit: 1eda9bfd6129a0da4cb6e4619d230ab0e08d33f9
      https://github.com/llvm/llvm-project/commit/1eda9bfd6129a0da4cb6e4619d230ab0e08d33f9
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-06-06 (Sat, 06 Jun 2020)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp

  Log Message:
  -----------
  [SCEV] ScalarEvolution::createSCEV(): Instruction::Or: drop bogus no-wrap flag detection

Summary:
That's just really wrong. While sure, if LHS is AddRec, and we could
propagate it's no-wrap flags, that doesn't make, because as long as
the operands of `or` had no common bits set, then the `add`
of these operands will never overflow: http://volta.cs.utah.edu:8080/z/gmt7Sy
IOW we need no propagation/detection, we are free to just set NUW+NSW.

But as rG39e3683534c83573da5c8b70c8adfb43948f601f shows,
even when the old code failed to "deduce" flags,
we'd eventually re-deduce them somewhere, later.

So let's just set them.

Reviewers: mkazantsev, reames, sanjoy, efriedma

Reviewed By: efriedma

Subscribers: efriedma, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81246


Compare: https://github.com/llvm/llvm-project/compare/ff1210edb69e...1eda9bfd6129


More information about the All-commits mailing list