[PATCH] D103877: [SCEV] Keep common flags when inlining SCEVAddExpr operands.

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 08:02:21 PDT 2021


mkazantsev added a comment.

As far as I understand what is a `nsw` for multi-argument add, it means that there should be no wrap in between if we add the operands one by one in any order. Imagine the case when `a = c = SINT_MIN` and `b = d = SINT_MAX`. We can say that `a+b` has `<nsw>`, `c+d` has `<nsw>`, and `(a+b) + (c+d)` also has `nsw`. But if we say that `getAddExpr(getAddExpr(a, b, nsw), getAddExpr(c, d, nsw), nsw) = getAddExpr(a, b, c, d, nsw)`, it's not true if we compute the latter as `a + c + b + d`. It will overflow on `a + c` already. Is my understanding wrong here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103877/new/

https://reviews.llvm.org/D103877



More information about the llvm-commits mailing list