llvm-project/llvm/lib/Transforms
Roman Lebedev b79b4f539b [InstCombine] Fold 'check for [no] signed truncation' pattern
Summary:
[[ https://bugs.llvm.org/show_bug.cgi?id=38149 | PR38149 ]]

As discussed in https://reviews.llvm.org/D49179#1158957 and later,
the IR for 'check for [no] signed truncation' pattern can be improved:
https://rise4fun.com/Alive/gBf
^ that pattern will be produced by Implicit Integer Truncation sanitizer,
https://reviews.llvm.org/D48958 https://bugs.llvm.org/show_bug.cgi?id=21530
in signed case, therefore it is probably a good idea to improve it.

Proofs for this transform: https://rise4fun.com/Alive/mgu
This transform is surprisingly frustrating.
This does not deal with non-splat shift amounts, or with undef shift amounts.
I've outlined what i think the solution should be:
```
  // Potential handling of non-splats: for each element:
  //  * if both are undef, replace with constant 0.
  //    Because (1<<0) is OK and is 1, and ((1<<0)>>1) is also OK and is 0.
  //  * if both are not undef, and are different, bailout.
  //  * else, only one is undef, then pick the non-undef one.
```

The DAGCombine will reverse this transform, see
https://reviews.llvm.org/D49266

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: JDevlieghere, rkruppe, llvm-commits

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

llvm-svn: 337190
2018-07-16 16:45:42 +00:00
..
AggressiveInstCombine Sort includes + include a missing `extern "C"` header 2018-07-10 22:48:13 +00:00
Coroutines Move Analysis/Utils/Local.h back to Transforms 2018-06-04 21:23:21 +00:00
Hello
IPO Restore "[ThinLTO] Ensure we always select the same function copy to import" 2018-07-16 15:30:27 +00:00
InstCombine [InstCombine] Fold 'check for [no] signed truncation' pattern 2018-07-16 16:45:42 +00:00
Instrumentation MSan: minor fixes, NFC 2018-07-16 10:57:19 +00:00
ObjCARC ProvenanceAnalysis: Store WeakTrackingVH instead of Value* in UnderlyingValue Cache. 2018-06-21 05:14:00 +00:00
Scalar [LSR] If no Use is interesting, early return. 2018-07-13 23:40:00 +00:00
Utils Fix comments which mixed up 'before' and 'after', NFC 2018-07-13 22:39:31 +00:00
Vectorize [SLPVectorizer] Add initial alternate opcode support for cast instructions. (REAPPLIED-2) 2018-07-13 11:09:52 +00:00
CMakeLists.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00
LLVMBuild.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00