[PATCH] D91153: [IndVarSimplify] Fix Modified status when handling dead PHI nodes

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 02:53:22 PST 2020


dstenb added inline comments.


================
Comment at: llvm/test/Transforms/IndVarSimplify/Mips/rewrite-loop-exit-values-phi.ll:33
+
+target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
+target triple = "mipsel"
----------------
mkazantsev wrote:
> Please commit this test separately with current auto-generated checks (use utils/update_test_checks.py for it). Then, with your code change, update the automated checks. It will clearly show what exactly your patch changes.
I do not think that that is possible in this case, since the test in itself will trigger the "Pass modifies its input and doesn't report it" unreachable when using an EXPENSIVE_CHECKS build without this bug fix. There is unfortunately no CLI option to disable those checks.

Here is at least the diff when using a non-EXPENSIVE_CHECKS build:

```
--- before.txt  2020-11-18 11:45:13.535990930 +0100
+++ after.txt   2020-11-18 11:43:02.432981959 +0100
@@ -8,7 +8,7 @@
   br label %for.cond3.preheader.i
 
 for.cond3.preheader.i:                            ; preds = %for.inc10.i, %entry
-  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc10.i ], [ undef, %entry ]
+  %dec.lcssa7.i = phi i64 [ undef, %entry ], [ %0, %for.inc10.i ]
   br label %for.body5.i
 
 for.cond12.preheader.i:                           ; preds = %for.inc10.i
@@ -16,7 +16,7 @@
   unreachable
 
 for.body5.i:                                      ; preds = %for.body5.i, %for.cond3.preheader.i
-  %dec5.i = phi i64 [ %indvars.iv, %for.cond3.preheader.i ], [ %dec.i, %for.body5.i ]
+  %dec5.i = phi i64 [ %dec.lcssa7.i, %for.cond3.preheader.i ], [ %dec.i, %for.body5.i ]
   %storemerge13.i = phi i32 [ 6, %for.cond3.preheader.i ], [ %dec9.i, %for.body5.i ]
   %dec.i = add nsw i64 %dec5.i, -1
   %xor.i = xor i64 %dec5.i, undef
@@ -27,6 +27,6 @@
 for.inc10.i:                                      ; preds = %for.body5.i
   %dec5.i.lcssa = phi i64 [ %dec5.i, %for.body5.i ]
   %xor.i.lcssa = phi i64 [ %xor.i, %for.body5.i ]
-  %indvars.iv.next = add i64 %indvars.iv, -6
+  %0 = add i64 %dec.lcssa7.i, -6
   br i1 true, label %for.cond12.preheader.i, label %for.cond3.preheader.i
 }
```

The dead PHI that previously was left behind was coalesced with the `%dec.lcssa7.i` PHI in subsequent runs of IndVars, so the IR is basically the same with or without this patch for the run of the attached reproducer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91153/new/

https://reviews.llvm.org/D91153



More information about the llvm-commits mailing list