[all-commits] [llvm/llvm-project] a2b212: [MLIR][Presburger] subtract: fix bug in the non-re...

Arjun P via All-commits all-commits at lists.llvm.org
Mon Apr 11 12:45:29 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a2b212bafc9508e54f94b1dce7a46e21ff9b5e91
      https://github.com/llvm/llvm-project/commit/a2b212bafc9508e54f94b1dce7a46e21ff9b5e91
  Author: Arjun P <arjunpitchanathan at gmail.com>
  Date:   2022-04-11 (Mon, 11 Apr 2022)

  Changed paths:
    M mlir/lib/Analysis/Presburger/PresburgerRelation.cpp

  Log Message:
  -----------
  [MLIR][Presburger] subtract: fix bug in the non-recursive implementation

When making the subtract implementation non-recursive, tail calls were
implemented by incrementing the level but not pushing a frame, and returning
was implemented as returning to the level corresponding to the number of frames in the stack.

This is incorrect, as there could be a case where we tail-recurse at `level`,
and then recurse at `level + 1`, pushing a frame. However, because the previous
frame was missing, this new frame would be interpreted as corresponding to
`level` and not `level + 1`. Fix this by removing the special handling of tail
calls and just doing them as normal recursion, as this is the simplest correct
implementation and handling them specifically would be a premature optimization.

The impact of this bug is only on performance as this can only lead to
unnecessary subtractions of the same disjuncts multiples times. As subtraction
is idempotent, and rationally empty disjuncts are always discarded, this
does not affect the output, so this patch does not include a regression test.
(This also does not affect termination.)

Reviewed By: Groverkss

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




More information about the All-commits mailing list