[PATCH] D119965: [LICM][PhaseOrder] Don't speculate in LICM until after running loop rotate

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 08:35:04 PDT 2022


lebedev.ri added a comment.

In D119965#3426448 <https://reviews.llvm.org/D119965#3426448>, @Carrot wrote:

>> There are two ways to view this;
>>
>> 1. if all of the IV's of PHI are fully identical instructions with fully identical operands, then we don't need to PHI together the operands, and can replace the PHI with said instruction.
>> 2. The one-user check there is there to ensure that the instruction count does not increase, so in principle, if we need to PHI together the operands, we need as many of the instructions to be one-user as many PHI's we need.
>
> I'm thinking of the following change, so we can remove PHI instruction without introduce any extra instructions on any path.
>
>   BB1:
>      br %cond, label %BB2, label %BB3
>   
>   BB2:
>      ...
>     %161 = or i64 %24, 1
>     ...
>      br label BBX
>   
>   BB3:
>      ...
>     %179 = or i64 %24, 1
>     ...
>      br label BBX
>   
>   BBX:
>      // our interesting bb
>     %245 = phi i64 [ %161, %BB2 ], [ %179, %BB3 ]
>     ...
>     %296 = mul nsw i64 %245, %5, !dbg !2155
>     %297 = getelementptr inbounds float, float* %4, i64 %296, !dbg !2156
>     ...
>   
>   ==>
>   
>   BB1:
>      ...
>      // New instruction is inserted here
>      %245 = or i64 %24, 1
>      br %cond, label %BB2, label %BB3
>   
>   BB2:
>      ...
>     ...
>      br label BBX
>   
>   BB3:
>      ...
>     // Use of %245.
>     ...
>      br label BBX
>   
>   BBX:
>     // our interesting bb
>     // PHI instruction is deleted.
>     ...
>     %296 = mul nsw i64 %245, %5, !dbg !2155
>     %297 = getelementptr inbounds float, float* %4, i64 %296, !dbg !2156
>     ...

That kinda sounds like something for GVNHoist, which i think is currently still disabled due to some miscompilations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119965



More information about the llvm-commits mailing list