[PATCH] D76483: [DivRemPairs] Freeze operands if they can be undef values

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 06:04:40 PDT 2020


sanwou01 added a comment.

>> [...] It looks like SCEV can't see "through" the freeze node. [...]
> 
> I see. This link might be helpful: https://reviews.llvm.org/D70623

Ah, so it is quite difficult to extend SCEV. (at least, it's making my head hurt already!)

I tried turning off `DivRemPairs` during the pre-link optimzations, but this also broke the optimization in SCEV/loop-reduce, so I don't think it will help to move `DivRemPairs` later in the pipe.

I'm not sure I understand the other workaround.

However, I did manage to reduce the regression:

  $ clang --target=aarch64-linux-gnu -O3 -flto -fno-strict-aliasing -o reduced.o -c reduced.c
  $ clang --target=aarch64-linux-gnu -O3 -flto -fno-strict-aliasing -o reduced reduced.o

`reduced.c:`

  typedef long a;
  struct arc {
    int b;
  } * h;
  typedef struct {
    a c;
    struct arc arcs;
    a d, e, f;
  } g;
  g j;
  a k, m;
  g *l;
  a n();
  int main() { n(&j); }
  a o(a p) {
    a q = p % l->d;
    if (q > l->e)
      k = p / l->d + (l->e * l->f + (q - l->e) * (l->f - 1));
    else
      k = p / l->d + l->f;
    return k;
  }
  a n(g *p) {
    a i;
    for (i = 0; i < p->c; i++, h = &p->arcs + o(++m))
      h->b = m;
    return 0;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76483





More information about the llvm-commits mailing list