[PATCH] D102171: [InstSimplify] Constant fold cast expressions with no already folded ops

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 10 07:56:04 PDT 2021


bjope added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4552
+  if (auto *C = dyn_cast<Constant>(Op)) {
+    C = ConstantFoldConstant(C, Q.DL);
     return ConstantFoldCastOperand(CastOpc, C, Ty, Q.DL);
----------------
Maybe this is an ugly solution. But I could not really figure out what to do.

I had some problems with infinite recursion if doing this directly inside `ConstantFoldCastOperand`. That is why this patch is doing it before the call to `ConstantFoldCastOperand`. Should ConstantFoldCastOperand expect that operands already are folded (kind of like in this patch), and then the implementation of ConstantFoldCastOperand doesn't need to handle recursive folding?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102171



More information about the llvm-commits mailing list