Commit Graph

11 Commits

Author SHA1 Message Date
Eric Christopher
598198edbc Revert "Temporarily Revert "Add basic loop fusion pass.""
The reversion apparently deleted the test/Transforms directory.

Will be re-reverting again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358552 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-17 04:52:47 +00:00
Eric Christopher
02cc44c1b9 Temporarily Revert "Add basic loop fusion pass."
As it's causing some bot failures (and per request from kbarton).

This reverts commit r358543/ab70da07286e618016e78247e4a24fcb84077fda.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358546 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-17 02:12:23 +00:00
Hiroshi Inoue
d967b3d2e7 [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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338485 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01 04:40:32 +00:00
Hiroshi Inoue
9325cc92ed [InstSimplify] tests for D48828, D49981: fold extraction from std::pair
Minor touch up in the previous comment.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338351 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-31 05:29:20 +00:00
Hiroshi Inoue
24f705031b [InstSimplify] tests for D48828, D49981: fold extraction from std::pair
Updated unit tests for D48828 and D49981.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338350 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-31 05:10:36 +00:00
Hiroshi Inoue
7eb8348d10 [InstSimplify] tests for D48828: fold extraction from std::pair
This commit includes unit tests for D48828, which enhances InstSimplify to enable jump threading with a method whose return type is std::pair<int, bool> or std::pair<bool, int>.
I am going to commit the actual transformation later.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338107 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-27 07:21:02 +00:00
Sanjay Patel
5f8dac1929 [InstSimplify] fold shifts by sext bool
https://rise4fun.com/Alive/c3Y


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335633 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 17:31:38 +00:00
Sanjay Patel
84f6f2281a [InstSimplify] add tests for shifts by sext bool; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335631 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 17:15:07 +00:00
Sanjay Patel
e1bbe84207 [PatternMatch] allow undef elements when matching a vector zero
This is the last step in getting constant pattern matchers to allow
undef elements in constant vectors.

I'm adding a dedicated m_ZeroInt() function and building m_Zero() from
that. In most cases, calling code can be updated to use m_ZeroInt()
directly when there's no need to match pointers, but I'm leaving that
efficiency optimization as a follow-up step because it's not always
clear when that's ok.

There are just enough icmp folds in InstSimplify that can be used for 
integer or pointer types, that we probably still want a generic m_Zero()
for those cases. Otherwise, we could eliminate it (and possibly add a
m_NullPtr() as an alias for isa<ConstantPointerNull>()).

We're conservatively returning a full zero vector (zeroinitializer) in
InstSimplify/InstCombine on some of these folds (see diffs in InstSimplify),
but I'm not sure if that's actually necessary in all cases. We may be 
able to propagate an undef lane instead. One test where this happens is 
marked with 'TODO'.
 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330550 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 17:07:44 +00:00
Sanjay Patel
03c56176d2 [InstSimplify, InstCombine] add vector tests with undef elts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330543 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 14:19:37 +00:00
Sanjay Patel
ce3569799c [InstSimplify] move tests for shifts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330516 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-21 16:58:00 +00:00