[all-commits] [llvm/llvm-project] eede48: [SCEV] Allow negative steps for LT exit count comp...

Philip Reames via All-commits all-commits at lists.llvm.org
Thu Sep 9 14:31:02 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eede4846a99b3680204768958160d041af4d3546
      https://github.com/llvm/llvm-project/commit/eede4846a99b3680204768958160d041af4d3546
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-09-09 (Thu, 09 Sep 2021)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll

  Log Message:
  -----------
  [SCEV] Allow negative steps for LT exit count computation for unsigned comparisons

This bit of code is incredibly suspicious. It allows fully unknown (but potentially negative) steps, but not steps known to be negative. The comment about scev flag inference is worrying, but also not correct to my knowledge.

At best, this might be covering up some related miscompile. However, there's no test in tree for it, the review history doesn't include obvious motivation, and the C++ example doesn't appear to give wrong results when hand translated to IR. I think it's time to remove this and see what falls out.

During review, there were concerns raised about the correctness of the corresponding signed case.  This change was deliberately narrowed to the unsigned case which has been auditted and appears correct for negative values.  We need to get back to the known-negative signed case, but that'll be a future patch if nothing falls out from this one.

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




More information about the All-commits mailing list