Yingwei Zheng
0b9f1cc024
[SCEV] Disallow simplifying phi(undef, X) to X (#115109)
See the following case:
```
@GlobIntONE = global i32 0, align 4
define ptr @src() {
entry:
br label %for.body.peel.begin
for.body.peel.begin: ; preds = %entry
br label %for.body.peel
for.body.peel: ; preds = %for.body.peel.begin
br i1 true, label %cleanup.peel, label %cleanup.loopexit.peel
cleanup.loopexit.peel: ; preds = %for.body.peel
br label %cleanup.peel
cleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel
%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]
br i1 true, label %for.body.peel.next, label %cleanup7
for.body.peel.next: ; preds = %cleanup.peel
br label %for.body.peel.next1
for.body.peel.next1: ; preds = %for.body.peel.next
br label %entry.peel.newph
entry.peel.newph: ; preds = %for.body.peel.next1
br label %for.body
for.body: ; preds = %cleanup, %entry.peel.newph
%retval.0 = phi ptr [ %retval.2.peel, %entry.peel.newph ], [ %retval.2, %cleanup ]
br i1 false, label %cleanup, label %cleanup.loopexit
cleanup.loopexit: ; preds = %for.body
br label %cleanup
cleanup: ; preds = %cleanup.loopexit, %for.body
%retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ]
br i1 false, label %for.body, label %cleanup7.loopexit
cleanup7.loopexit: ; preds = %cleanup
%retval.2.lcssa.ph = phi ptr [ %retval.2, %cleanup ]
br label %cleanup7
cleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel
%retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ]
ret ptr %retval.2.lcssa
}
define ptr @tgt() {
entry:
br label %for.body.peel.begin
for.body.peel.begin: ; preds = %entry
br label %for.body.peel
for.body.peel: ; preds = %for.body.peel.begin
br i1 true, label %cleanup.peel, label %cleanup.loopexit.peel
cleanup.loopexit.peel: ; preds = %for.body.peel
br label %cleanup.peel
cleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel
%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]
br i1 true, label %for.body.peel.next, label %cleanup7
for.body.peel.next: ; preds = %cleanup.peel
br label %for.body.peel.next1
for.body.peel.next1: ; preds = %for.body.peel.next
br label %entry.peel.newph
entry.peel.newph: ; preds = %for.body.peel.next1
br label %for.body
for.body: ; preds = %cleanup, %entry.peel.newph
br i1 false, label %cleanup, label %cleanup.loopexit
cleanup.loopexit: ; preds = %for.body
br label %cleanup
cleanup: ; preds = %cleanup.loopexit, %for.body
br i1 false, label %for.body, label %cleanup7.loopexit
cleanup7.loopexit: ; preds = %cleanup
%retval.2.lcssa.ph = phi ptr [ %retval.2.peel, %cleanup ]
br label %cleanup7
cleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel
%retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ]
ret ptr %retval.2.lcssa
}
```
1. `simplifyInstruction(%retval.2.peel)` returns `@GlobIntONE`. Thus,
`ScalarEvolution::createNodeForPHI` returns SCEV expr `@GlobIntONE` for
`%retval.2.peel`.
2. `SimplifyIndvar::replaceIVUserWithLoopInvariant` tries to replace the
use of `%retval.2.peel` in `%retval.2.lcssa.ph` with `@GlobIntONE`.
3. `simplifyLoopAfterUnroll -> simplifyLoopIVs -> SCEVExpander::expand`
reuses `%retval.2.peel = phi ptr [ undef, %for.body.peel ], [
@GlobIntONE, %cleanup.loopexit.peel ]` to generate code for
`@GlobIntONE`. It is incorrect.
This patch disallows simplifying `phi(undef, X)` to `X` by setting
`CanUseUndef` to false.
Closes https://github.com/llvm/llvm-project/issues/114879.
2024-11-07 15:53:51 +08:00
..
2024-11-06 11:53:33 +00:00
2024-09-03 09:16:37 -07:00
2024-11-06 11:53:33 +00:00
2023-12-08 09:56:55 +00:00
2024-10-31 15:58:15 +08:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2023-05-17 17:03:15 +02:00
2024-06-26 10:18:01 +01:00
2024-11-06 11:53:33 +00:00
2023-05-17 17:03:15 +02:00
2024-05-15 14:03:21 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-05 14:22:24 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-09-04 16:28:39 +05:30
2023-06-12 13:10:22 +02:00
2024-10-23 04:34:13 +01:00
2024-09-19 09:41:25 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2023-10-28 17:47:46 +08:00
2023-10-24 20:27:39 -07:00
2024-06-14 15:07:27 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-10-17 16:50:59 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-08-28 19:12:05 +01:00
2024-11-06 11:53:33 +00:00
2024-10-31 21:36:44 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-09-21 19:47:37 +01:00
2024-11-06 11:53:33 +00:00
2024-07-21 14:03:40 +01:00
2024-10-31 21:36:44 +01:00
2024-11-06 11:53:33 +00:00
2024-07-05 10:08:42 +01:00
2023-04-17 13:08:15 +01:00
2024-11-06 11:53:33 +00:00
2024-07-05 10:08:42 +01:00
2023-11-27 12:54:11 -08:00
2024-08-27 11:55:47 +01:00
2024-09-27 13:08:55 +01:00
2023-11-29 13:19:50 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-01-31 13:31:28 +00:00
2024-11-06 11:53:33 +00:00
2024-01-31 13:31:28 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-10-31 21:36:44 +01:00
2024-11-05 22:45:56 +01:00
2024-11-06 11:53:33 +00:00
2024-10-16 07:21:58 +01:00
2023-12-05 14:09:36 +01:00
2023-08-08 18:10:23 -04:00
2024-07-01 09:26:01 +02:00
2024-11-06 11:53:33 +00:00
2024-06-14 17:18:20 -04:00
2024-08-21 12:02:54 +02:00
2024-11-06 11:53:33 +00:00
2024-09-19 18:50:10 +01:00
2024-11-06 11:53:33 +00:00
2023-09-28 21:15:34 +08:00
2023-09-29 22:18:32 +08:00
2023-09-29 22:18:32 +08:00
2024-02-05 11:57:34 +01:00
2024-09-23 09:56:37 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2023-10-28 17:47:46 +08:00
2023-06-20 13:17:28 -04:00
2024-10-17 16:50:59 +01:00
2024-10-17 16:50:59 +01:00
2024-11-06 11:53:33 +00:00
2024-10-02 11:45:00 +02:00
2024-11-06 11:53:33 +00:00
2024-08-11 20:38:36 +02:00
2024-11-06 11:53:33 +00:00
2023-09-20 12:08:52 +05:30
2024-07-05 21:41:31 +01:00
2024-09-28 14:19:57 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-10-02 10:28:54 +01:00
2024-11-06 11:53:33 +00:00
2024-09-10 10:41:35 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-03-26 16:01:57 +01:00
2024-11-06 11:53:33 +00:00
2023-11-21 10:54:36 +00:00
2023-05-01 13:55:11 -07:00
2024-07-07 20:08:01 +01:00
2023-04-17 13:49:49 +01:00
2024-11-06 11:53:33 +00:00
2024-09-14 21:21:55 +01:00
2024-11-06 11:53:33 +00:00
2024-07-01 09:52:56 -07:00
2023-12-05 14:09:36 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-01-26 11:13:05 +00:00
2024-10-02 11:45:00 +02:00
2023-08-29 11:42:18 +01:00
2024-11-06 11:53:33 +00:00
2023-03-07 17:10:34 +01:00
2024-11-06 11:53:33 +00:00
2024-10-10 20:04:46 +01:00
2024-07-14 20:49:03 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2023-11-29 13:19:50 +00:00
2024-11-06 11:53:33 +00:00
2023-02-15 14:07:51 -08:00
2024-07-05 10:08:42 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-09-22 22:08:46 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-09-19 09:41:25 +01:00
2024-11-06 11:53:33 +00:00
2024-01-16 21:54:58 -08:00
2024-01-31 13:31:28 +00:00
2024-01-16 21:54:58 -08:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-08-14 10:19:29 +01:00
2024-10-02 11:45:00 +02:00
2024-11-06 11:53:33 +00:00
2024-10-31 21:36:44 +01:00
2024-09-10 10:41:35 +01:00
2023-12-08 12:18:31 +00:00
2024-06-26 14:25:54 +01:00
2024-07-05 10:08:42 +01:00
2024-09-20 11:22:03 +01:00
2024-10-23 04:34:13 +01:00
2024-11-06 11:53:33 +00:00
2023-06-12 13:10:22 +02:00
2023-08-29 11:42:18 +01:00
2023-10-17 03:49:39 +08:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2023-07-11 19:12:59 -07:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-10-17 16:50:59 +01:00
2024-10-17 16:50:59 +01:00
2024-10-17 16:50:59 +01:00
2024-11-06 11:53:33 +00:00
2024-09-20 11:22:03 +01:00
2023-08-03 00:37:19 -07:00
2024-07-05 10:08:42 +01:00
2024-07-05 10:08:42 +01:00
2023-08-29 11:42:18 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-03-26 16:01:57 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-09-20 11:22:03 +01:00
2024-07-05 10:08:42 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-08-21 12:02:54 +02:00
2024-11-07 15:53:51 +08:00
2023-12-05 14:09:36 +01:00
2023-10-28 17:47:46 +08:00
2024-08-19 12:40:20 +01:00
2024-10-17 16:50:59 +01:00
2024-11-06 11:53:33 +00:00
2024-10-16 06:10:19 +01:00
2024-01-31 13:31:28 +00:00
2024-09-19 18:50:10 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2023-04-25 21:47:14 +01:00
2024-09-06 11:20:14 +02:00
2024-04-16 09:48:13 -04:00
2024-11-06 11:53:33 +00:00
2024-02-20 16:43:57 +00:00
2024-10-08 22:37:20 +01:00
2024-04-04 18:30:17 -04:00
2024-07-07 20:08:01 +01:00
2024-10-31 21:36:44 +01:00
2024-10-31 21:36:44 +01:00
2024-10-31 21:36:44 +01:00
2024-10-31 21:36:44 +01:00
2024-10-31 21:36:44 +01:00
2024-10-31 21:36:44 +01:00
2024-10-31 21:36:44 +01:00
2024-10-18 05:52:35 +01:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-11-06 11:53:33 +00:00
2024-09-20 11:22:03 +01:00