[all-commits] [llvm/llvm-project] b7af34: [LSR] Add a test case for (another) miscompile in ...

Philip Reames via All-commits all-commits at lists.llvm.org
Tue Mar 21 08:13:18 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b7af34c303ca3dc53ee5945b0c692b3b10ebae94
      https://github.com/llvm/llvm-project/commit/b7af34c303ca3dc53ee5945b0c692b3b10ebae94
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2023-03-21 (Tue, 21 Mar 2023)

  Changed paths:
    M llvm/test/Transforms/LoopStrengthReduce/lsr-term-fold.ll

  Log Message:
  -----------
  [LSR] Add a test case for (another) miscompile in lsr-term-fold

Derived from an observation by @nikic on D146457.


  Commit: b33f5e7ed3cd04797b721e32b982b2cf6e06e192
      https://github.com/llvm/llvm-project/commit/b33f5e7ed3cd04797b721e32b982b2cf6e06e192
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2023-03-21 (Tue, 21 Mar 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    M llvm/test/Transforms/LoopStrengthReduce/lsr-term-fold.ll

  Log Message:
  -----------
  [LSR] Use evaluateAtIteration in lsr-term-fold

This is a follow up to one of the side discussions on D146429.  There are two semantic changes contained here.

The motivation for the change to the legality condition introduced in D146429 comes from the fact that we only check the post-inc form. As such, as long as the values of the post-inc variable don't self wrap, it's actually okay if we wrap past the starting value of the pre-inc IV.

Second, Nikic noticed during review that the test changes changed behavior for TC=0 (i.e. N=0 in the tests).  On more careful inspection, it became apparent that the previous manual expansion code was incorrect in the case where the primary IV could wrap without poison, and started with the limit value (i.e. i8 post-inc starts at 255 for 0 exit test, implying pre-inc starts with 0).  See @wrap_around test for an example of the (previous) miscompile.

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


Compare: https://github.com/llvm/llvm-project/compare/faa1043144b3...b33f5e7ed3cd


More information about the All-commits mailing list