[IRBuilder] Migrate all binops to folding API
authorNikita Popov <npopov@redhat.com>
Thu, 30 Jun 2022 10:52:31 +0000 (12:52 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 30 Jun 2022 14:41:17 +0000 (16:41 +0200)
commitf34dcf27637f5b657d9e244187631243bfccc25a
tree802e58919bb6d689193bb0fb6a4d02ccb7478116
parent8e9360db1b4128ad4d90a6fe1cf1c20879976f64
[IRBuilder] Migrate all binops to folding API

Migrate all binops to use FoldXYZ rather than CreateXYZ APIs,
which are compatible with InstSimplifyFolder and fallible constant
folding.

Rather than continuing to add one method for every single operator,
add a generic FoldBinOp (plus variants for nowrap, exact and fmf
operators), which we would need anyway for CreateBinaryOp.

This change is not NFC because IRBuilder with InstSimplifyFolder
may perform more folding. However, this patch changes SCEVExpander
to not use the folder in InsertBinOp to minimize practical impact
and keep this change as close to NFC as possible.
llvm/include/llvm/Analysis/InstSimplifyFolder.h
llvm/include/llvm/Analysis/TargetFolder.h
llvm/include/llvm/IR/ConstantFolder.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/IRBuilderFolder.h
llvm/include/llvm/IR/NoFolder.h
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp