Yingwei Zheng
f7ef0721d6
[SCEV] Do not allow refinement in the rewriting of BEValue (#117152)
See the following case:
```
; bin/opt -passes="print<scalar-evolution>" test.ll --disable-output
define i32 @widget() {
b:
br label %b1
b1: ; preds = %b5, %b
%phi = phi i32 [ 0, %b ], [ %udiv6, %b5 ]
%phi2 = phi i32 [ 1, %b ], [ %add, %b5 ]
%icmp = icmp eq i32 %phi, 0
br i1 %icmp, label %b3, label %b8
b3: ; preds = %b1
%udiv = udiv i32 10, %phi2
%urem = urem i32 %udiv, 10
%icmp4 = icmp eq i32 %urem, 0
br i1 %icmp4, label %b7, label %b5
b5: ; preds = %b3
%udiv6 = udiv i32 %phi2, 0
%add = add i32 %phi2, 1
br label %b1
b7: ; preds = %b3
ret i32 5
b8: ; preds = %b1
ret i32 7
}
```
```
%phi2 = phi i32 [ 1, %b ], [ %add, %b5 ] --> {1,+,1}<nuw><nsw><%b1>
%udiv6 = udiv i32 %phi2, 0 --> ({1,+,1}<nuw><nsw><%b1> /u 0)
%phi = phi i32 [ 0, %b ], [ %udiv6, %b5 ] --> ({0,+,1}<nuw><nsw><%b1> /u 0)
```
`ScalarEvolution::createAddRecFromPHI` gives a wrong SCEV result for
`%phi`:
d7d6fb1804/llvm/lib/Analysis/ScalarEvolution.cpp (L5926-L5950)
It converts `phi(0, ({1,+,1}<nuw><nsw><%b1> /u 0))` into `phi(0 / 0,
({1,+,1}<nuw><nsw><%b1> /u 0))`. Then it simplifies the expr into
`{0,+,1}<nuw><nsw><%b1> /u 0`.
As we did in
acd700a24b,
this patch disallows udiv simplification if we cannot prove that the
denominator is a well-defined non-zero value.
Fixes https://github.com/llvm/llvm-project/issues/117133.
2024-12-01 20:11:09 +08:00
..
2024-11-15 14:19:50 +00:00
2023-12-15 15:49:25 +01:00
2023-10-26 12:07:37 -07:00
2023-05-17 17:03:15 +02:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2024-11-15 14:19:50 +00:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2024-11-15 14:19:50 +00:00
2023-10-31 14:37:57 -07:00
2022-12-13 14:50:13 +01:00
2022-12-14 15:37:58 +01:00
2023-12-05 14:09:36 +01:00
2024-11-15 14:19:50 +00:00
2024-01-25 16:05:54 +08:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2023-11-07 07:25:47 -08:00
2022-12-14 15:37:58 +01:00
2023-11-08 11:16:23 +00:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2023-11-03 08:42:59 -07:00
2024-10-02 11:45:00 +02:00
2023-01-20 15:52:07 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-04-16 10:42:32 +09:00
2023-01-11 11:36:02 +07:00
2024-11-15 14:19:50 +00:00
2024-05-20 11:47:30 +02:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-14 15:37:58 +01:00
2022-12-13 14:50:13 +01:00
2023-10-09 14:42:09 +02:00
2024-11-15 09:15:37 +08:00
2024-05-20 11:47:30 +02:00
2022-12-13 14:50:13 +01:00
2024-04-16 10:42:32 +09:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-07 15:53:51 +08:00
2022-12-13 14:50:13 +01:00
2024-02-01 11:01:29 +00:00
2024-04-16 10:42:32 +09:00
2024-04-16 10:42:32 +09:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2022-12-14 15:37:58 +01:00
2024-10-02 11:45:00 +02:00
2022-12-13 14:50:13 +01:00
2023-04-27 15:07:19 +02:00
2022-12-14 15:37:58 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-02-10 18:11:17 +00:00
2024-10-02 11:45:00 +02:00
2024-11-15 14:19:50 +00:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-14 15:37:58 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2023-07-12 14:35:55 +02:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2024-04-16 10:42:32 +09:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-14 15:37:58 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2024-11-15 14:19:50 +00:00
2022-12-14 15:37:58 +01:00
2024-02-10 18:11:17 +00:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2024-06-04 08:31:03 +02:00
2024-04-16 10:42:32 +09:00
2023-12-05 14:09:36 +01:00
2023-06-03 22:29:09 +08:00
2023-03-14 10:55:02 +01:00
2023-05-31 11:21:35 +02:00
2023-08-22 09:27:07 +02:00
2023-12-05 14:09:36 +01:00
2023-09-18 08:23:10 +02:00
2023-09-21 14:22:01 +02:00
2023-10-09 16:35:01 +02:00
2024-02-05 10:11:39 +01:00
2024-08-12 15:24:37 +02:00
2024-08-28 12:56:01 +02:00
2024-11-21 17:23:04 +08:00
2024-12-01 20:11:09 +08:00
2023-04-25 16:40:37 +07:00
2022-12-13 14:50:13 +01:00
2024-02-10 18:11:17 +00:00
2022-12-13 14:50:13 +01:00
2024-07-02 15:01:48 +01:00
2024-07-10 13:02:58 +01:00
2024-05-09 12:58:53 +01:00
2023-12-07 13:20:36 -08:00
2023-04-29 21:33:30 +01:00
2023-03-14 10:55:02 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-08-21 12:02:54 +02:00
2024-09-19 09:39:35 +02:00
2022-12-13 14:50:13 +01:00
2022-12-14 15:37:58 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2022-12-13 14:50:13 +01:00
2024-01-25 16:05:54 +08:00
2023-06-01 09:46:16 +02:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-11-15 14:19:50 +00:00
2023-08-09 18:33:11 -04:00
2023-11-07 07:25:47 -08:00
2024-06-03 13:25:55 +01:00
2023-11-07 07:25:47 -08:00
2023-02-10 13:57:39 +07:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2022-12-13 14:50:13 +01:00
2024-02-10 18:11:17 +00:00
2024-04-16 10:42:32 +09:00
2024-04-16 10:42:32 +09:00
2023-10-31 09:33:07 -07:00