[PATCH] D129352: [CodeGen] Limit building time for CodeGenPrepare
Xiang Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 02:39:26 PDT 2022
xiangzhangllvm added inline comments.
================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7103
+ // So we put the operands defs' BBs into FreshBBs to do optmization.
+ for (unsigned I = 0; I < NI->getNumOperands(); ++I) {
+ auto *OpDef = dyn_cast<Instruction>(NI->getOperand(I));
----------------
xiangzhangllvm wrote:
> LuoYuanke wrote:
> > xiangzhangllvm wrote:
> > > LuoYuanke wrote:
> > > > The instruction is cloned. Why the def of its operand need to be sinked?
> > > When we copy an Instruction (to a new place) to do optimization, means we updated an instruction. This instruction's operand defs may have new opportunity to sink to the optimized new instruction.
> > Here we just copy the instruction. We know it is sinked when it is erased in line 7135.
> Let me try give an example soon.
I find an ARM case about it, it not about sink, it about copy 2 times:
**1st time**: copy insertelement from entry to vector.body
```
entry:
...
1 %l0 = trunc i16 %x to i8
2 %l1 = insertelement <8 x i8> undef, i8 %l0, i32 0
...
3 br label %vector.body
vector.body: ; preds = %vector.body, %entry
...
4 %0 = insertelement <8 x i8> undef, i8 %l0, i32 0 // copy from line 2
5 %1 = shufflevector <8 x i8> %0, <8 x i8> undef, <8 x i32> zeroinitializer
6 %l9 = mul <8 x i8> %1, %l8
```
**2nd time**, copy insertelement's operand trunc
```
...
1 %l0 = trunc i16 %x to i8
2 %l1 = insertelement <8 x i8> undef, i8 %l0, i32 0
...
3 br label %vector.body
vector.body: ; preds = %vector.body, %entry
...
%0 = trunc i16 %x to i8 // 2nd copy optimization
%1 = insertelement <8 x i8> undef, i8 %0, i32 0 // use 2nd copy
%2 = shufflevector <8 x i8> %1, <8 x i8> undef, <8 x i32> zeroinitializer
%l9 = mul <8 x i8> %2, %l8
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129352/new/
https://reviews.llvm.org/D129352
More information about the llvm-commits
mailing list