[PATCH] D77523: Add CanonicalizeFreezeInLoops pass

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 03:14:44 PDT 2020


aqjune marked 3 inline comments as done and 4 inline comments as done.
aqjune added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/CanonicalizeFreezeInLoops.cpp:163
+    if (!isGuaranteedNotToBeUndefOrPoison(StepValue, PN, &DT)) {
+      unsigned OpIdx = SteppingInst->getOperand(1) == StepValue;
+      SteppingInst->setOperand(
----------------
fhahn wrote:
> I think currently cases where we have multiple candidates for the same PHI are not handled correctly at the moment here, as after handling the first candidate the step operand will  not match the original StepValue. Multiple candidates would be added for a loop like the one below I think.
> 
> ```
> loop:
>   %i = phi i32 [%init, %entry], [%i.next, %loop]
>   %i.fr = freeze i32 %i
>   call void @call(i32 %i.fr)
>   %i.next = add nsw nuw i32 %i, %step
>   %i.next.fr = freeze i32 %i.next
>   %cond = icmp eq i32 %i.next, %n
>   call void @call(i32 %i.next.fr)
>   br i1 %cond, label %loop, label %exit
> ```
Now this case will be correctly handled. Have a test add_multiuses2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77523





More information about the llvm-commits mailing list