Go to file
Hiroshi Inoue 02f79eae06 [InstSimplify] fold extracting from std::pair (1/2)
This patch intends to enable jump threading when a method whose return type is std::pair<int, bool> or std::pair<bool, int> is inlined.
For example, jump threading does not happen for the if statement in func.

std::pair<int, bool> callee(int v) {
  int a = dummy(v);
  if (a) return std::make_pair(dummy(v), true);
  else return std::make_pair(v, v < 0);
}

int func(int v) {
  std::pair<int, bool> rc = callee(v);
  if (rc.second) {
    // do something
  }

SROA executed before the method inlining replaces std::pair by i64 without splitting in both callee and func since at this point no access to the individual fields is seen to SROA.
After inlining, jump threading fails to identify that the incoming value is a constant due to additional instructions (like or, and, trunc).

This series of patch add patterns in InstructionSimplify to fold extraction of members of std::pair. To help jump threading, actually we need to optimize the code sequence spanning multiple BBs.
These patches does not handle phi by itself, but these additional patterns help NewGVN pass, which calls instsimplify to check opportunities for simplifying instructions over phi, apply phi-of-ops optimization to result in successful jump threading. 
SimplifyDemandedBits in InstCombine, can do more general optimization but this patch aims to provide opportunities for other optimizers by supporting a simple but common case in InstSimplify.

This first patch in the series handles code sequences that merges two values using shl and or and then extracts one value using lshr.

Differential Revision: https://reviews.llvm.org/D48828

llvm-svn: 338485
2018-08-01 04:40:32 +00:00
clang [OpenEmbedded] Explicitly specify -rtlib in tests 2018-08-01 03:30:06 +00:00
clang-tools-extra [clang-tidy] add all clang-tidy modules to plugin 2018-07-31 15:23:49 +00:00
compiler-rt [compiler-rt] Add a routine to specify the mode used when creating profile dirs. 2018-07-31 23:37:24 +00:00
debuginfo-tests [DWARF] Change a test to ensure the creation of a __debug_ranges section. 2018-07-31 19:37:29 +00:00
libclc atom: Use volatile pointers for cl_khr_{global,local}_int32_{base,extended}_atomics 2018-06-21 19:27:39 +00:00
libcxx [libc++][C++17] Elementary string conversions for integral types 2018-08-01 02:38:30 +00:00
libcxxabi [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY 2018-08-01 02:08:59 +00:00
libunwind [CMake] Include CMakeDependentOption in libunwind 2018-07-24 23:42:51 +00:00
lld Allow oformat to accept format starting with elf as acceptable format. isOutputFormatBinary returns false in such case. 2018-07-31 21:58:26 +00:00
lldb Android is an environment and we were comparing the android triple 2018-07-31 23:53:24 +00:00
llgo Update copyright year to 2018. 2018-06-18 12:22:17 +00:00
llvm [InstSimplify] fold extracting from std::pair (1/2) 2018-08-01 04:40:32 +00:00
openmp [OpenMP] Fix tasking + parallel bug 2018-07-30 21:47:56 +00:00
parallel-libs Update copyright year to 2018. 2018-06-18 12:22:17 +00:00
polly [JSONExporter] Try to appease buildbot. NFC. 2018-08-01 00:48:01 +00:00
README.md

README.md

Low Level Virtual Machine (LLVM)

This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.