[PATCH] D119965: [LICM][PhaseOrder] Don't speculate in LICM until after running loop rotate
Guozhi Wei via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 4 14:24:27 PDT 2022
Carrot added a comment.
>> 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?
I tried GVNHoist, it works as expected, moves the "or" instruction to BB1.
But BB1 is in a loop, later LICM moves the "or" instruction to the loop preheader. Unfortunately another identical "or" instruction exists in one of its predecessors, I encountered the same problem as before GVNHoist, but this time no GVNHoist can hoist the "or" instruction, and later GVNPass creates a PHI for it.
Can I add another GVNHoist pass after loop optimizations?
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