- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
[IA][RISCV] Detecting gap mask from a mask assembled by interleaveN intrinsics #153510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
53fe83e
              17e9bec
              7c00c1c
              0ca6f75
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -596,7 +596,26 @@ static std::pair<Value *, APInt> getMask(Value *WideMask, unsigned Factor, | |||||||||||||||||||
| 
     | 
||||||||||||||||||||
| if (auto *IMI = dyn_cast<IntrinsicInst>(WideMask)) { | ||||||||||||||||||||
| if (unsigned F = getInterleaveIntrinsicFactor(IMI->getIntrinsicID()); | ||||||||||||||||||||
| F && F == Factor && llvm::all_equal(IMI->args())) { | ||||||||||||||||||||
| F && F == Factor) { | ||||||||||||||||||||
| Value *RefArg = nullptr; | ||||||||||||||||||||
| // Check if all the intrinsic arguments are the same, except those that | ||||||||||||||||||||
| // are zeros, which we mark them as gaps in the gap mask. | ||||||||||||||||||||
| for (auto [Idx, Arg] : enumerate(IMI->args())) { | ||||||||||||||||||||
| if (auto *C = dyn_cast<Constant>(Arg); C && C->isZeroValue()) { | ||||||||||||||||||||
| GapMask.clearBit(Idx); | ||||||||||||||||||||
| continue; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| 
     | 
||||||||||||||||||||
| if (!RefArg) | ||||||||||||||||||||
| RefArg = Arg; | ||||||||||||||||||||
| 
     | 
||||||||||||||||||||
| if (RefArg != Arg) | ||||||||||||||||||||
| return {nullptr, GapMask}; | ||||||||||||||||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, this can be an else if? 
        Suggested change
       
    
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed  | 
||||||||||||||||||||
| } | ||||||||||||||||||||
| 
     | 
||||||||||||||||||||
| // In a very rare occasion, all the intrinsic arguments might be zeros, | ||||||||||||||||||||
| // in which case we still want to return an all-zeros constant instead of | ||||||||||||||||||||
| // nullptr, so we're not using RefArg here. | ||||||||||||||||||||
| return {IMI->getArgOperand(0), GapMask}; | ||||||||||||||||||||
                
       | 
||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| 
          
            
          
           | 
    ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -205,6 +205,23 @@ define {<4 x i32>, <4 x i32>} @vpload_factor2_interleaved_mask_intrinsic(ptr %pt | |||||||||
| ret {<4 x i32>, <4 x i32>} %res1 | ||||||||||
| } | ||||||||||
| 
     | 
||||||||||
| define {<2 x i32>, <2 x i32>} @vpload_factor4_interleaved_mask_intrinsic_skip_fields(ptr %ptr, <2 x i1> %m) { | ||||||||||
| ; mask = %m, skip the last two fields. | ||||||||||
                
       | 
||||||||||
| define {<2 x i32>, <2 x i32>} @vpload_factor4_interleaved_mask_intrinsic_skip_fields(ptr %ptr, <2 x i1> %m) { | |
| ; mask = %m, skip the last two fields. | |
| ; mask = %m, skip the last two fields. | |
| define {<2 x i32>, <2 x i32>} @vpload_factor4_interleaved_mask_intrinsic_skip_fields(ptr %ptr, <2 x i1> %m) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test with zero as the first operand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought about it, but right now RISCV does not support non-trailing gap, so the transformation wouldn't kick in (and thus the emitted code will look the same) regardless of whether we return the correct value like now or incorrect one like I did before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.