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-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-11-07 08:11:15 +00:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-11-07 08:11:15 +00:00
2024-11-07 08:11:15 +00:00
2024-11-15 10:03:08 +00:00
2024-06-03 13:25:55 +01:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-11-07 08:11:15 +00:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-05-20 07:40:54 +02:00
2024-09-23 09:56:37 +01:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-11-07 08:11:15 +00:00
2024-03-06 13:08:05 -08:00
2023-11-24 15:49:28 +01:00
2024-09-23 09:56:37 +01:00
2024-08-29 17:53:32 +01:00
2024-03-06 10:24:32 -08:00
2024-06-20 15:59:42 +02:00
2024-03-06 13:08:05 -08:00
2023-11-03 11:19:14 -07:00
2024-11-07 08:11:15 +00:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2023-11-24 15:49:28 +01:00
2023-11-24 15:49:28 +01:00
2024-03-06 13:08:05 -08:00
2024-10-03 16:02:34 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-09-28 14:19:57 +01:00
2024-08-22 14:45:14 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-11-07 08:11:15 +00:00
2024-03-06 08:48:25 -08:00
2024-11-07 08:11:15 +00:00
2024-11-07 08:11:15 +00:00
2024-11-07 08:11:15 +00:00
2024-11-07 08:11:15 +00:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-04-10 09:02:23 -04:00
2024-06-25 14:33:57 -07:00
2024-11-21 17:23:04 +08:00
2024-12-01 20:11:09 +08:00
2024-09-23 09:56:37 +01:00
2024-09-28 14:19:57 +01:00
2024-09-23 09:56:37 +01:00
2023-11-24 15:49:28 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-04-12 18:21:48 +09:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-06-05 08:05:07 -07:00
2024-11-07 08:11:15 +00:00
2024-11-07 08:11:15 +00:00
2024-10-02 11:45:00 +02:00
2024-11-07 08:11:15 +00:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2023-11-08 11:29:12 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-11-07 08:11:15 +00:00
2023-11-24 15:49:28 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-11-07 08:11:15 +00:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-09-23 09:56:37 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-08-12 11:40:24 -07:00
2024-03-06 13:08:05 -08:00
2024-06-19 08:59:26 -07:00
2024-09-28 14:19:57 +01:00
2024-03-06 15:57:34 -08:00
2024-03-06 10:24:32 -08:00
2024-03-06 10:24:32 -08:00
2024-09-05 17:01:56 +02:00
2024-10-14 13:08:49 +01:00
2024-03-06 10:24:32 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 13:08:05 -08:00
2024-03-06 10:24:32 -08:00