[PATCH] D115247: [EarlyCSE] Retain poison flags, if program is UB if poison.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 10 08:26:22 PST 2021


reames requested changes to this revision.
reames added a comment.
This revision now requires changes to proceed.

Conceptually this is clear enough, but I'm worried about compile time impact.  Do you have any numbers to share?  This looks potentially quite expensive as the analysis to prove UB if poison is not really cacheable.

We can improve compile time by e.g. only doing the search on things which might produce poison flags, but the first step is knowing if we have a problem.



================
Comment at: llvm/lib/Transforms/Scalar/EarlyCSE.cpp:1369
         }
-        if (auto *I = dyn_cast<Instruction>(V))
-          I->andIRFlags(&Inst);
+        if (auto *I = dyn_cast<Instruction>(V)) {
+          if (programUndefinedIfPoison(I)) {
----------------
Per LangRef, nnan and ninf are poison generating.  The handling on the other FMF flags is unclear to me.  I'd suggest as a stepping stone restricting the preservation of flags to non-float instructions while leaving a clear TODO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115247



More information about the llvm-commits mailing list