[PATCH] D108910: [IndVars] Break backedge and replace PHIs if loop exits on 1st iteration

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 30 02:47:05 PDT 2021


mkazantsev added a comment.

Fine by me with nits, but please get someone else's approval.



================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1320
+  }
+  for (auto *PN : LoopPHINodes) {
+    PN->eraseFromParent();
----------------
{ } not needed


================
Comment at: llvm/test/Transforms/IndVarSimplify/eliminate-backedge.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p
+; RUN: opt < %s -indvars -S | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
----------------
Please add another run commant with `-passes=indvars` (new PM).


================
Comment at: llvm/test/Transforms/IndVarSimplify/eliminate-backedge.ll:65
+  %baz_ret = call i1 @baz()
+  br i1 %baz_ret, label %latch, label %exit
+
----------------
Can you pls make one of the exits leave the loop by `true` condition and stay by `false` condition, just to see how the branch get folded in this case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108910



More information about the llvm-commits mailing list