[LLVMdev] Boolean simplification in LLVM

Hans Wennborg hans at chromium.org
Wed Jun 17 09:41:38 PDT 2015


On Tue, Jun 16, 2015 at 6:57 PM, Anirudh Sivaraman <sk.anirudh at gmail.com> wrote:
> I am trying to implement if-conversion as an LLVM pass. My reference
> is Chapter 7 of the book ""Optimizing Compilers for Modern
> Architectures", based on the suggestion here:
> https://groups.google.com/d/msg/llvm-dev/FlDGnqSGbR8/eH5hO9IBbXYJ Some
> steps in the if-conversion pass require simplification of Boolean
> Expressions. Is this doable within the LLVM API? llvm::ConstantExpr
> seems like the data structure to use, but I haven't found a way to
> simplify a value represented by a ConstantExpr.

Do you need simplification (e.g. "x + 0 = x") or constant folding? If
it's the former, see include/llvm/Analysis/InstructionSimplify.h. For
the latter, check out the functions in
include/llvm/Analysis/ConstantFolding.h.

Cheers,
Hans



More information about the llvm-dev mailing list