Juneyoung Lee
aacf7878bc
[ValueTracking] Improve impliesPoison
...
This patch improves ValueTracking's impliesPoison(V1, V2) to do this reasoning:
```
%res = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
%overflow = extractvalue { i64, i1 } %res, 1
%mul = extractvalue { i64, i1 } %res, 0
; If %mul is poison, %overflow is also poison, and vice versa.
```
This improvement leads to supporting this optimization under `-instcombine-unsafe-select-transform=0`:
```
define i1 @test2_logical(i64 %a, i64 %b, i64* %ptr) {
; CHECK-LABEL: @test2_logical(
; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 [[A]], 0
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i64 [[B]], 0
; CHECK-NEXT: [[OVERFLOW_1:%.*]] = and i1 [[TMP1]], [[TMP2]]
; CHECK-NEXT: [[NEG:%.*]] = sub i64 0, [[MUL]]
; CHECK-NEXT: store i64 [[NEG]], i64* [[PTR:%.*]], align 8
; CHECK-NEXT: ret i1 [[OVERFLOW_1]]
;
%res = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
%overflow = extractvalue { i64, i1 } %res, 1
%mul = extractvalue { i64, i1 } %res, 0
%cmp = icmp ne i64 %mul, 0
%overflow.1 = select i1 %overflow, i1 true, i1 %cmp
%neg = sub i64 0, %mul
store i64 %neg, i64* %ptr, align 8
ret i1 %overflow.1
}
```
Previously, this didn't happen because the flag prevented `select i1 %overflow, i1 true, i1 %cmp` from being `or i1 %overflow, %cmp`.
Note that the select -> or conversion happens only when `impliesPoison(%cmp, %overflow)` returns true.
This improvement allows `impliesPoison` to do the reasoning.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D96929
2021-02-20 13:22:34 +09:00
..
2020-08-25 14:19:39 -07:00
2021-02-12 21:42:49 +01:00
2021-02-06 11:17:10 -08:00
2020-04-21 11:32:58 +01:00
2020-04-21 11:32:58 +01:00
2021-02-06 11:17:10 -08:00
2020-10-19 14:31:17 -07:00
2021-02-14 08:36:20 -08:00
2021-02-11 12:17:38 -06:00
2021-02-19 11:05:42 +01:00
2020-05-07 11:58:00 -07:00
2020-02-04 10:05:28 -08:00
2021-02-06 11:17:10 -08:00
2020-12-23 21:57:25 -08:00
2020-12-03 16:52:14 -08:00
2021-02-06 11:17:10 -08:00
2020-11-07 12:57:00 +01:00
2020-12-11 21:19:31 -08:00
2021-01-06 18:27:36 -08:00
2020-11-19 21:53:50 +01:00
2019-11-13 16:34:37 -08:00
2021-01-16 09:40:55 -08:00
2021-02-16 22:47:14 -08:00
2021-02-11 12:17:38 -06:00
2021-01-10 17:37:27 +01:00
2021-01-12 21:43:46 -08:00
2020-12-11 08:12:54 +00:00
2021-01-22 23:25:01 -08:00
2020-12-16 12:37:36 -05:00
2021-02-06 11:17:10 -08:00
2021-02-19 12:35:40 +01:00
2020-11-26 18:39:55 +01:00
2021-01-22 23:25:01 -08:00
2021-01-22 23:25:01 -08:00
2021-02-16 10:26:45 +05:30
2019-11-13 16:34:37 -08:00
2020-04-06 17:42:54 +00:00
2021-01-08 18:39:54 -08:00
2020-12-02 18:42:44 +00:00
2021-01-10 09:24:57 -08:00
2021-02-18 23:07:50 +01:00
2020-02-18 10:49:13 +08:00
2020-06-17 13:02:58 +02:00
2021-01-20 13:33:43 -08:00
2021-02-18 17:01:32 -08:00
2021-01-25 15:38:57 -08:00
2021-01-21 20:29:17 -08:00
2020-12-11 20:28:39 -08:00
2020-08-21 12:39:42 +03:00
2020-04-20 18:25:31 +02:00
2021-02-15 13:39:43 +00:00
2020-12-12 10:09:35 -08:00
2019-11-13 16:34:37 -08:00
2021-02-09 12:11:47 -06:00
2021-02-19 14:01:57 -05:00
2019-11-13 16:34:37 -08:00
2019-11-13 16:34:37 -08:00
2019-11-13 16:34:37 -08:00
2021-01-14 20:30:33 -08:00
2021-02-06 11:17:10 -08:00
2021-02-16 10:26:45 +05:30
2020-11-26 18:39:55 +01:00
2021-02-13 13:03:11 +01:00
2021-01-09 09:25:00 -08:00
2020-12-03 18:25:05 +03:00
2021-01-22 23:25:01 -08:00
2021-02-14 08:36:20 -08:00
2021-01-22 23:25:01 -08:00
2020-12-14 22:40:13 -08:00
2020-06-17 15:48:23 +01:00
2020-12-19 10:57:35 -08:00
2020-11-23 11:56:22 -08:00
2021-01-22 16:03:01 -05:00
2021-01-24 12:18:57 -08:00
2020-12-20 17:52:48 +01:00
2021-02-04 20:58:28 +01:00
2021-01-06 14:53:09 -08:00
2021-01-20 13:33:43 -08:00
2020-10-19 14:31:17 -07:00
2021-01-27 10:43:51 -08:00
2021-01-28 22:21:16 -08:00
2020-11-26 18:39:55 +01:00
2020-12-03 18:25:05 +03:00
2021-02-12 09:51:57 -08:00
2020-12-23 22:47:36 +07:00
2020-10-23 20:14:02 +02:00
2019-11-22 21:29:08 +00:00
2020-07-09 16:38:19 -07:00
2020-07-23 17:50:22 +01:00
2020-10-21 10:54:55 -07:00
2020-04-06 17:42:54 +00:00
2020-12-01 10:33:18 -08:00
2021-01-25 15:38:57 -08:00
2021-02-19 08:29:12 -08:00
2020-11-26 18:39:55 +01:00
2020-09-18 10:05:02 +01:00
2020-12-17 14:04:48 +03:00
2020-09-07 11:43:16 +08:00
2021-01-09 09:25:00 -08:00
2021-02-14 08:36:14 -08:00
2020-04-22 00:07:13 -07:00
2021-02-12 11:07:58 +00:00
2021-02-16 13:50:06 +00:00
2020-11-18 21:20:21 -08:00
2021-02-17 23:58:44 -08:00
2020-06-05 17:40:33 +01:00
2020-03-31 12:50:20 +01:00
2020-07-09 18:33:09 +01:00
2021-02-20 13:22:34 +09:00
2021-02-12 09:38:12 +00:00
2021-01-18 10:16:36 -08:00