[PATCH] D93820: [InstSimplify] Don't fold gep p, -p to null

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 26 04:10:18 PST 2020


nlopes added a comment.

I only looked at the tests and they were correct before, see here: https://alive2.llvm.org/ce/z/UzW3pv
The tests are weird because they have 'gep inbounds'. The reason they are correct (and weird) is that the only way `p - (int)p/sizeof(*p)` is inbounds is p being null. Anything else will overflow.

The code is buggy because it doesn't require inbounds (not caught because there's no test without inbounds): https://gcc.godbolt.org/z/GYxc78

So in the end the transformation doesn't seem very useful in practice?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93820



More information about the llvm-commits mailing list