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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 7 01:45:01 PDT 2021


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

I think there are two patches here - `ExitsOnFirstIter`, and `replaceLoopPHINodesWithPreheaderValues()` change.
I think it may be nice to split the patch into two, with `replaceLoopPHINodesWithPreheaderValues()` being the first one.

I think there's generality that may be missing here.
We know which exit exits on the first iteration, which means that all the following exits are not reached.
But does that tell us anything about the preceding exits?
I'm roughly thinking about this situation: https://godbolt.org/z/KdKb3jzqW (ignore that it is optimized already)

Also, much like with that simplifycfg patch, should we be emitting assumptions here?

All that being said, seems reasonable.



================
Comment at: llvm/test/Transforms/IndVarSimplify/floating-point-iv.ll:345
 ; CHECK-NEXT:    [[IV_FP:%.*]] = sitofp i64 [[IV]] to double
-; CHECK-NEXT:    [[TMP0:%.*]] = tail call i32 @foo(double [[IV_FP]]) [[ATTR0]]
+; CHECK-NEXT:    [[TMP0:%.*]] = tail call i32 @foo(double [[IV_FP]]) #[[ATTR0]]
 ; CHECK-NEXT:    [[IV_NEXT]] = add nuw i64 [[IV]], 1
----------------
Please regenerate the checklines in the affected test files before committing the actual patch.


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