[PATCH] D110060: [LoopBoundSplit] Handle the case in which exiting block is loop header

JinGu Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 23 23:46:23 PDT 2021


jaykang10 added inline comments.


================
Comment at: llvm/test/Transforms/LoopBoundSplit/bug51866.ll:39
+; CHECK-NEXT:    [[I_0_SPLIT:%.*]] = phi i16 [ [[INC_SPLIT:%.*]], [[FOR_INC_SPLIT:%.*]] ], [ 5, [[FOR_COND_SPLIT_PREHEADER]] ]
+; CHECK-NEXT:    [[I_1_SPLIT:%.*]] = phi i16 [ [[INC_SPLIT]], [[FOR_INC_SPLIT]] ], [ 10, [[FOR_COND_SPLIT_PREHEADER]] ]
+; CHECK-NEXT:    [[EXITCOND_NOT_SPLIT:%.*]] = icmp eq i16 [[I_0_SPLIT]], 10
----------------
mkazantsev wrote:
> jaykang10 wrote:
> > mkazantsev wrote:
> > > Why is it 10 again?
> > Ah, you are right! I made a mistake. The incoming value from preheader in post-loop should be new bound. Let me update it.
> And why is it 5?.. It should be 15, no?
um... The `%i.1` is not AddRecExpr...
```
for.cond: 
  %i.0 = phi i16 [ 0, %entry ], [ %inc, %for.inc ]
  %i.1 = phi i16 [ 10, %entry ], [ %inc, %for.inc ]
...
for.inc:                                          ; preds = %if.else, %if.then
  %inc = add nuw nsw i16 %i.0, 1
```
The value of `%i.1` will be 10 at first iteration and it will follow `%inc` at next iterations. In this case, the start value of `%i.1` in post loop is 5. If `%i.1` is AddRecExpr as below, the start value will be 15.
``` 
for.cond: 
  %i.0 = phi i16 [ 0, %entry ], [ %inc, %for.inc ]
  %i.1 = phi i16 [ 10, %entry ], [ %inc.1, %for.inc ]
...
for.inc:                                          ; preds = %if.else, %if.then
  %inc = add nuw nsw i16 %i.0, 1
  %inc.1 = add nuw nsw i16 %i.1, 1
```
I think you mention the case where the phi is AddRecExpr and the code is missing the case. Let me check and update the code. Thanks for the detailed review.


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

https://reviews.llvm.org/D110060



More information about the llvm-commits mailing list