[PATCH] D110322: [ConstantFolding] Fold constrained compare intrinsics

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 30 12:20:13 PDT 2021


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1854
     if (EB && *EB != fp::ExceptionBehavior::ebIgnore)
-      CI->addFnAttr(Attribute::ReadNone);
+      const_cast<ConstrainedFPIntrinsic *>(CI)->addFnAttr(Attribute::ReadNone);
     return true;
----------------
kpn wrote:
> This still worries me. Are _analysis_ passes allowed to change the input IR? What if the caller decides to not do a fold after calling this function to see if a fold is possible? And why is the ebIgnore case different from the other two?
> 
> Constant folding won't add this ReadNone attribute when the constant folding code doesn't have an Instruction to alter. I don't know what to do about that.
Analysis passes are indeed not allowed to change the IR. And this isn't a harmless change either if it gets left behind -- e.g. it invalidates MemorySSA.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110322



More information about the llvm-commits mailing list