[PATCH] D29316: Add predicateinfo intrinsic, analysis pass, and basic NewGVN support

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 00:38:13 PST 2017


sanjoy added a comment.

> Just moving them would not actually invalidate them (since they have all the info in them necessary to give correct answers)

Wouldn't speculating them be a problem?  That is:

  int x = ...;
  if (0 s< x s< 20) {
    x_ = predicate_info(x) // attached icmp 0 s< x s< 20
    r0 = 1 / (x_ + 1);
    print r0;
  }

to

  int x = ...;
  x_ = predicate_info(x) // attached icmp 0 s< x s< 20
  if (0 s< x s< 20) {
    r0 = 1 / (x_ + 1);
    print r0;
  }

to (division safe to speculate since it divides by `[1, 20)` + `1` =
`[2, 21)`):

  int x = ...;
  x_ = predicate_info(x) // attached icmp 0 s< x s< 20
  r0 = 1 / (x_ + 1);
  if (0 s< x s< 20) {
    print r0;
  }

but now you could divide by zero if `x` was `-1`.

Generally, (as I've mentioned on IRC) the only concern I had with this was the compile time hit we may have because of the extra dereferences that will now be necessary to go from a use to its "true" operand.


https://reviews.llvm.org/D29316





More information about the llvm-commits mailing list