[PATCH] D136095: [GVN] Patch for invalid GVN replacement

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 08:27:13 PDT 2022


nikic added a comment.

Here is my current understanding of the issue: For loads of GEPs, we try to perform scalar PRE during the main GVN pass, while for everything else it is done afterwards, see: https://github.com/llvm/llvm-project/blob/524c640090a8463305acbafd7606f1db3c1256e2/llvm/lib/Transforms/Scalar/GVN.cpp#L1777-L1783

Scalar PRE will insert the new instruction into the leader table for the predecessor here: https://github.com/llvm/llvm-project/blob/524c640090a8463305acbafd7606f1db3c1256e2/llvm/lib/Transforms/Scalar/GVN.cpp#L2768-L2769

In this example, we process the blocks in the order entry, bb1, bb3, bb2. When we process bb2, we add the PRE'd instruction to the leader table of bb2, so when we visit bb2, it thinks that the instruction is already available.

I don't think that the fix implemented here is the right one -- I think we need to either prevent PRE from happening in this case, or prevent the incorrect insertion into the leader table, or something along those lines.


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

https://reviews.llvm.org/D136095



More information about the llvm-commits mailing list