Roman Lebedev
1cd41cb270
[InstCombine] Re-commit: 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.
The DAGCombine will reverse this transform, see
https://reviews.llvm.org/D49266
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.
```
This is a re-commit, as the original patch, committed in rL337190
was reverted in rL337344 as it broke chromium build:
https://bugs.llvm.org/show_bug.cgi?id=38204 and
https://crbug.com/864832
Proofs that the fixed folds are ok: https://rise4fun.com/Alive/VYM
Differential Revision: https://reviews.llvm.org/D49320
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337376 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-18 10:55:17 +00:00
..
2018-05-09 02:40:45 +00:00
2018-05-09 02:40:45 +00:00
2018-05-14 13:43:32 +00:00
2018-02-22 18:55:59 +00:00
2018-03-02 00:59:27 +00:00
2018-05-09 02:40:45 +00:00
2018-03-12 22:28:18 +00:00
2018-04-23 20:09:08 +00:00
2018-05-11 22:49:49 +00:00
2018-07-09 22:21:16 +00:00
2018-05-09 02:40:45 +00:00
2018-06-14 22:58:48 +00:00
2018-05-11 03:12:28 +00:00
2018-07-09 22:27:23 +00:00
2018-02-15 22:26:18 +00:00
2018-05-09 02:40:45 +00:00
2018-07-02 04:49:30 +00:00
2018-06-14 13:02:13 +00:00
2018-05-09 02:40:45 +00:00
2018-01-06 16:16:04 +00:00
2018-07-09 22:27:23 +00:00
2018-07-16 15:30:27 +00:00
2018-05-09 02:40:45 +00:00
2018-06-06 14:48:32 +00:00
2018-07-10 16:34:23 +00:00
2018-04-27 23:15:56 +00:00
2018-07-09 22:27:23 +00:00
2018-07-16 07:51:27 +00:00
2018-01-22 22:05:25 +00:00
2018-06-28 08:20:03 +00:00
2018-02-02 16:07:16 +00:00
2018-05-16 11:39:52 +00:00
2018-07-13 16:32:31 +00:00
2018-07-18 10:55:17 +00:00
2018-05-09 06:52:12 +00:00
2018-07-17 12:31:54 +00:00
2018-07-17 14:04:59 +00:00
2018-05-19 13:06:37 +00:00
2018-06-26 22:19:48 +00:00
2018-05-24 23:00:23 +00:00
2018-07-04 13:28:39 +00:00
2018-07-04 13:28:39 +00:00
2018-05-09 02:40:45 +00:00
2018-01-12 07:24:43 +00:00
2018-05-09 02:40:45 +00:00
2018-07-11 22:35:28 +00:00
2018-05-29 20:15:38 +00:00
2018-07-04 13:28:39 +00:00
2018-03-22 16:03:59 +00:00
2018-06-22 22:58:55 +00:00
2018-05-09 02:40:45 +00:00
2018-05-09 02:40:45 +00:00
2018-06-20 22:01:04 +00:00
2018-06-29 07:44:20 +00:00
2018-06-26 18:51:17 +00:00
2018-07-01 12:47:30 +00:00
2018-05-23 10:09:53 +00:00
2018-07-10 13:29:50 +00:00
2018-07-13 23:58:46 +00:00
2018-07-13 19:57:39 +00:00
2018-06-26 06:17:00 +00:00
2018-04-23 19:55:04 +00:00
2018-05-15 11:31:07 +00:00
2018-05-19 12:51:59 +00:00
2018-01-19 17:13:12 +00:00
2018-05-24 06:09:02 +00:00
2018-07-02 04:49:30 +00:00
2018-05-16 04:52:18 +00:00
2018-07-09 08:07:21 +00:00
2018-05-09 23:10:46 +00:00
2018-01-19 17:13:12 +00:00
2018-03-23 21:46:16 +00:00
2018-07-03 17:12:59 +00:00
2018-07-04 13:28:39 +00:00
2018-05-09 02:40:45 +00:00
2018-06-11 22:40:43 +00:00
2018-05-09 02:40:45 +00:00
2018-07-17 14:04:59 +00:00
2018-05-11 21:13:19 +00:00
2018-07-10 08:36:05 +00:00
2018-07-09 22:27:23 +00:00
2018-01-11 21:28:57 +00:00
2018-07-17 13:43:33 +00:00
2018-06-28 18:58:30 +00:00
2018-05-23 18:34:48 +00:00
2018-01-09 19:39:35 +00:00
2018-05-09 02:40:45 +00:00
2018-06-01 15:20:47 +00:00
2018-07-10 12:06:16 +00:00
2018-04-06 21:32:36 +00:00