[PATCH] D75407: [InstSimplify] Constant fold icmp of gep

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 2 13:19:16 PST 2020


efriedma added a comment.

> PS: Does someone know why we constant folding is separated in this way? I understand that we don't want to have ConstantExpr depend on TLI, but why can't it depend on DL?

This is sort of historical; deep in LLVM's history, we allowed generating/optimizing modules without a datalayout.  This turned out to be mostly useless in practice, so we abandoned it many years ago.  The two separate constant folders is one of the leftover traces of that.

It would be non-trivial to change at this point: in ConstantExpr::getICmp, there currently isn't any way to get a DataLayout.



================
Comment at: lib/Analysis/InstructionSimplify.cpp:3487
+          return FoldedICmp;
+        return NewICmp;
       }
----------------
If we need to repeat this pattern in multiple places, probably makes sense to factor this out into a helper.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75407





More information about the llvm-commits mailing list