Yingwei Zheng
a77dedcacb
[InstSimplify][InstCombine][ConstantFold] Move vector div/rem by zero fold to InstCombine ( #114280 )
...
Previously we fold `div/rem X, C` into `poison` if any element of the
constant divisor `C` is zero or undef. However, it is incorrect when
threading udiv over an vector select:
https://alive2.llvm.org/ce/z/3Ninx5
```
define <2 x i32> @vec_select_udiv_poison(<2 x i1> %x) {
%sel = select <2 x i1> %x, <2 x i32> <i32 -1, i32 -1>, <2 x i32> <i32 0, i32 1>
%div = udiv <2 x i32> <i32 42, i32 -7>, %sel
ret <2 x i32> %div
}
```
In this case, `threadBinOpOverSelect` folds `udiv <i32 42, i32 -7>, <i32
-1, i32 -1>` and `udiv <i32 42, i32 -7>, <i32 0, i32 1>` into
`zeroinitializer` and `poison`, respectively. One solution is to
introduce a new flag indicating that we are threading over a vector
select. But it requires to modify both `InstSimplify` and
`ConstantFold`.
However, this optimization doesn't provide benefits to real-world
programs:
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/IR/ConstantFold.cpp.html#L908
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp.html#L1107
This patch moves the fold into InstCombine to avoid breaking numerous
existing tests.
Fixes #114191 and #113866 (only poison-safety issue).
2024-11-01 22:56:22 +08:00
..
2024-10-22 12:55:15 +00:00
2024-09-27 15:33:52 +02:00
2024-10-22 12:55:15 +00:00
2024-10-31 09:24:51 -07:00
2024-08-31 11:52:27 +01:00
2024-08-21 12:02:54 +02:00
2024-10-28 17:45:08 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-07-24 23:39:30 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 23:15:24 +01:00
2024-06-14 15:07:27 +01:00
2024-10-28 22:51:35 +00:00
2024-08-21 12:02:54 +02:00
2024-10-16 16:24:44 +08:00
2024-10-16 16:24:44 +08:00
2024-10-23 09:12:08 -05:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-12 10:12:00 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-07-18 11:25:43 +02:00
2024-10-02 15:16:56 +02:00
2024-09-17 11:52:22 +01:00
2024-07-02 11:14:36 +02:00
2024-08-21 12:02:54 +02:00
2024-09-01 09:49:23 +08:00
2024-06-28 20:23:48 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-26 09:55:52 +02:00
2024-08-21 12:02:54 +02:00
2024-07-25 09:19:22 -04:00
2024-07-25 09:19:22 -04:00
2024-09-17 15:31:28 -07:00
2024-08-21 12:02:54 +02:00
2024-09-01 09:49:23 +08:00
2024-08-21 12:02:54 +02:00
2024-07-11 19:01:06 +08:00
2024-08-12 10:12:00 +02:00
2024-10-17 20:43:48 +08:00
2024-08-12 10:12:00 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-06 10:44:21 +01:00
2024-07-01 16:46:00 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-28 17:45:08 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-06-14 15:07:27 +01:00
2024-08-21 12:02:54 +02:00
2024-10-15 22:05:16 +04:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-09-23 15:41:22 +01:00
2024-09-01 09:49:23 +08:00
2024-08-21 12:02:54 +02:00
2024-06-14 15:07:27 +01:00
2024-10-28 17:45:08 +08:00
2024-08-19 16:09:46 +03:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-07-29 14:05:50 +02:00
2024-09-10 10:38:21 +08:00
2024-08-07 09:33:55 +01:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-08-07 09:33:55 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-09 15:22:54 +02:00
2024-11-01 22:56:22 +08:00
2024-10-10 09:54:25 +01:00
2024-10-17 14:57:38 +02:00
2024-06-14 15:07:27 +01:00
2024-10-22 12:58:11 +08:00
2024-06-28 16:52:03 +08:00
2024-06-27 20:10:33 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-15 17:32:16 +08:00
2024-10-21 22:30:31 +08:00
2024-08-21 12:02:54 +02:00
2024-10-10 14:44:39 +04:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-07-23 20:13:23 +08:00
2024-09-18 09:38:28 +01:00
2024-06-22 09:50:21 -07:00
2024-08-21 12:02:54 +02:00
2024-10-25 10:47:39 -07:00
2024-06-23 10:39:07 +01:00
2024-08-27 11:43:17 -07:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-11-01 12:22:57 +08:00
2024-08-24 19:56:59 +08:00
2024-08-21 12:02:54 +02:00
2024-09-15 14:25:00 +04:00
2024-08-02 21:21:31 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-15 17:11:25 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-10-06 10:44:21 +01:00
2024-09-13 11:15:22 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-16 19:13:52 +08:00
2024-08-21 12:02:54 +02:00
2024-09-01 09:49:23 +08:00
2024-08-21 12:02:54 +02:00
2024-10-16 19:13:52 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-09-24 09:39:07 +02:00
2024-10-17 20:43:48 +08:00
2024-10-17 20:43:48 +08:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-28 17:45:08 +08:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-09-18 19:10:41 +08:00
2024-10-17 20:43:48 +08:00
2024-10-23 09:12:08 -05:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-10-17 20:43:48 +08:00
2024-10-17 20:43:48 +08:00
2024-10-23 09:12:08 -05:00
2024-10-20 10:46:35 +08:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-10-01 11:44:13 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-12 11:06:25 +08:00
2024-10-17 20:43:48 +08:00
2024-10-02 15:16:56 +02:00
2024-08-21 12:02:54 +02:00
2024-10-02 11:18:48 +01:00
2024-08-21 12:02:54 +02:00
2024-07-02 15:11:14 +02:00
2024-07-30 00:56:53 +08:00
2024-06-14 15:07:27 +01:00
2024-06-14 15:07:27 +01:00
2024-10-17 20:43:48 +08:00
2024-08-04 09:32:40 +02:00
2024-07-29 11:28:03 -07:00
2024-10-07 23:21:42 +04:00
2024-10-21 11:27:15 -04:00
2024-10-10 09:54:25 +01:00
2024-10-10 09:54:25 +01:00
2024-10-10 07:56:16 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-06-14 15:07:27 +01:00
2024-10-17 20:43:48 +08:00
2024-08-15 18:08:23 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-01 22:46:07 +08:00
2024-08-27 00:11:23 +03:00
2024-10-17 20:43:48 +08:00
2024-08-01 22:46:07 +08:00
2024-10-15 22:05:16 +04:00
2024-10-15 22:05:16 +04:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-07-29 10:32:51 -07:00
2024-08-01 17:24:48 +08:00
2024-08-01 17:24:48 +08:00
2024-08-01 17:24:48 +08:00
2024-08-01 17:24:48 +08:00
2024-10-03 17:08:45 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-12 10:12:00 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-09 15:22:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-13 20:44:45 +02:00
2024-10-17 20:43:48 +08:00
2024-09-04 16:22:43 +02:00
2024-09-23 15:39:11 +01:00
2024-09-18 10:04:49 +02:00
2024-10-22 12:55:15 +00:00
2024-09-13 08:36:48 +01:00
2024-06-13 10:11:18 +02:00
2024-06-14 15:07:27 +01:00
2024-08-21 12:02:54 +02:00
2024-09-01 09:49:23 +08:00
2024-08-21 12:02:54 +02:00
2024-10-28 17:45:08 +08:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-07-01 14:52:06 +02:00
2024-08-17 16:48:29 +08:00
2024-07-09 22:04:55 +08:00
2024-08-09 12:52:56 +02:00
2024-10-17 20:43:48 +08:00
2024-10-28 15:09:20 +08:00
2024-08-21 12:02:54 +02:00
2024-07-29 11:28:03 -07:00
2024-06-26 18:54:40 -07:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-02 15:16:56 +02:00
2024-11-01 22:56:22 +08:00
2024-10-17 20:43:48 +08:00
2024-07-24 13:32:20 +08:00
2024-07-24 13:32:20 +08:00
2024-07-24 13:32:20 +08:00
2024-07-24 13:32:20 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-06-20 08:59:29 +02:00
2024-06-14 15:07:27 +01:00
2024-11-01 22:18:44 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-09-23 15:41:22 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-15 11:10:45 +01:00
2024-11-01 12:22:57 +08:00
2024-08-21 12:02:54 +02:00
2024-10-17 00:27:21 +08:00
2024-10-14 11:37:30 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-06-19 12:18:01 +02:00
2024-08-06 22:04:24 +08:00
2024-10-16 12:44:09 +01:00
2024-07-29 11:28:03 -07:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-07-17 22:57:42 +08:00
2024-08-21 12:02:54 +02:00
2024-09-23 15:41:22 +01:00
2024-10-15 11:10:45 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 23:15:24 +01:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-28 17:45:08 +08:00
2024-08-21 12:02:54 +02:00
2024-08-15 08:49:55 -07:00
2024-06-18 16:51:37 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-14 14:08:12 +01:00
2024-08-15 08:06:41 -07:00
2024-10-17 10:32:55 -05:00
2024-10-28 17:45:08 +08:00
2024-09-23 15:41:22 +01:00
2024-06-14 15:07:27 +01:00
2024-09-01 09:49:23 +08:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-02 09:07:48 -07:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-06-14 15:07:27 +01:00
2024-08-04 16:12:14 +03:00
2024-10-17 20:43:48 +08:00
2024-08-04 16:12:14 +03:00
2024-08-04 16:12:14 +03:00
2024-07-29 11:28:03 -07:00
2024-07-25 09:24:56 +02:00
2024-07-25 09:24:56 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-17 20:43:48 +08:00
2024-08-21 12:02:54 +02:00
2024-09-28 17:52:10 +01:00
2024-09-28 17:52:10 +01:00
2024-06-17 15:38:59 +02:00
2024-08-21 12:02:54 +02:00
2024-09-23 15:41:22 +01:00
2024-06-20 08:59:29 +02:00
2024-08-21 12:02:54 +02:00
2024-07-13 16:55:11 +02:00
2024-08-21 12:02:54 +02:00
2024-06-14 15:07:27 +01:00
2024-08-21 12:02:54 +02:00
2024-10-15 22:05:16 +04:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-08-21 12:02:54 +02:00
2024-10-29 10:39:07 +08:00
2024-07-17 14:36:11 -07:00
2024-08-21 12:02:54 +02:00
2024-11-01 22:56:22 +08:00
2024-08-21 12:02:54 +02:00
2024-08-28 12:48:20 +01:00
2024-08-21 12:02:54 +02:00
2024-10-10 14:44:39 +04:00
2024-08-21 12:02:54 +02:00
2024-09-22 12:32:17 +02:00
2024-08-21 12:02:54 +02:00
2024-10-28 17:45:08 +08:00
2024-09-01 09:49:23 +08:00
2024-08-21 20:09:02 +08:00