[PATCH] D106714: [Matrix] RAUW should only replace an instruction in ShapeMap if supportsShapeInfo

Adam Nemet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 23 14:17:45 PDT 2021


anemet created this revision.
anemet added a reviewer: fhahn.
Herald added subscribers: tschuett, hiraditya.
anemet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As an instruction is replaced in optimizeTransposes RAUW will replace it in                                                                                                                                                              
the ShapeMap (ShapeMap is ValueMap so that uses are updated).  In                                                                                                                                                                        
finalizeLowering however we skip updating uses if they are in the ShapeMap                                                                                                                                                               
since they will be lowered separately at which point we pick up the lowered                                                                                                                                                              
operands.

In the testcase what happened was that since we replaced the doubled-transpose                                                                                                                                                           
with the shuffle, it ended up in the ShapeMap.  As we lowered the                                                                                                                                                                        
columnwise-load the use in the shuffle was not updated.  Then as we removed                                                                                                                                                              
the original columnwise-load we changed that to an undef.  I.e. we ended up                                                                                                                                                              
with:

  %shuf = shufflevector <8 x double> undef, <8 x double> poison, <6 x i32>                                                                                                                                                                 
                                     ^^^^^                                                                                                                                                                                                 
                                    <i32 0, i32 1, i32 2, i32 4, i32 5, i32 6>                                                                                                                                                             

Besides the fix itself, I have fortified this last bit.  As we change uses to                                                                                                                                                            
undef when removing instruction we track the undefed instruction to make sure                                                                                                                                                            
we eventually remove those too.  This would have caught the issue at compile                                                                                                                                                             
time.


https://reviews.llvm.org/D106714

Files:
  llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
  llvm/test/Transforms/LowerMatrixIntrinsics/transpose-opts.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106714.361352.patch
Type: text/x-patch
Size: 6538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210723/b79970a8/attachment.bin>


More information about the llvm-commits mailing list