[IRBuilder] Introduce folder using inst-simplify, use for Or fold.
authorFlorian Hahn <flo@fhahn.com>
Tue, 11 Jan 2022 17:30:48 +0000 (17:30 +0000)
committerFlorian Hahn <flo@fhahn.com>
Tue, 11 Jan 2022 17:30:48 +0000 (17:30 +0000)
commitf0ef1ea6dd32c1518f826308b3d4a1e38e4973e9
tree4a968b281b180a33e8e4e1bbfb1f1f3528a5457b
parentee25a327aac0eeae28f468a741b58ec7689de5f2
[IRBuilder] Introduce folder using inst-simplify, use for Or fold.

Alternative to D116817.

This introduces a new value-based folding interface for Or (FoldOr),
which takes 2 values and returns an existing Value or a constant if the
Or can be simplified. Otherwise nullptr is returned. This replaces the
more restrictive CreateOr which takes 2 constants.

This is the used to implement a folder that uses InstructionSimplify.
The logic to simplify `Or` instructions is moved there. Subsequent
patches are going to transition other CreateXXX to the more general
FoldXXX interface.

Reviewed By: nikic, lebedev.ri

Differential Revision: https://reviews.llvm.org/D116935
25 files changed:
clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c
clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
clang/test/CodeGen/catch-pointer-overflow-volatile.c
clang/test/CodeGen/catch-pointer-overflow.c
clang/test/CodeGen/ubsan-pointer-overflow.c
clang/test/OpenMP/for_lastprivate_codegen.cpp
clang/test/OpenMP/for_linear_codegen.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_private_codegen.cpp
clang/test/OpenMP/parallel_reduction_codegen.cpp
clang/test/OpenMP/single_codegen.cpp
clang/test/OpenMP/teams_private_codegen.cpp
llvm/include/llvm/Analysis/InstSimplifyFolder.h [new file with mode: 0644]
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/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll
llvm/test/Transforms/LoopVectorize/runtime-check-small-clamped-bounds.ll
llvm/test/Transforms/LoopVersioning/wrapping-pointer-versioning.ll
llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll
llvm/test/Transforms/SROA/basictest.ll