- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
[RISCV] Add ISel patterns for Xqciac QC.MULIADD instruction #147661
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8e748ac
              
                [RISCV] Add ISel patterns for Xqciac QC.MULIADD instruction
              
              
                svs-quic 0201aea
              
                getSubtarget
              
              
                svs-quic bf0aca9
              
                Pass subtarget from caller
              
              
                svs-quic 7065ea2
              
                Merge branch 'main' into muliadd
              
              
                svs-quic 04a6a40
              
                Tests without ISelLowering changes
              
              
                svs-quic 49ecc01
              
                ISel changes for corner cases
              
              
                svs-quic File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=riscv32 -mattr=+m -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck %s -check-prefix=RV32IM | ||
| ; RUN: llc -mtriple=riscv32 -mattr=+m,+experimental-xqciac -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck %s -check-prefix=RV32IMXQCIAC | ||
| ; RUN: llc -mtriple=riscv32 -mattr=+m,+experimental-xqciac,+zba -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck %s -check-prefix=RV32IZBAMXQCIAC | ||
| 
     | 
||
| define dso_local i32 @mul(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: mul: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: slli a0, a1, 5 | ||
| ; RV32IM-NEXT: add a0, a0, a1 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: mul: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: li a0, 33 | ||
| ; RV32IMXQCIAC-NEXT: mul a0, a1, a0 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: mul: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: li a0, 33 | ||
| ; RV32IZBAMXQCIAC-NEXT: mul a0, a1, a0 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, 33 | ||
| ret i32 %mul | ||
| } | ||
| 
     | 
||
| define dso_local i32 @muliadd(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: muliadd: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: li a2, 165 | ||
| ; RV32IM-NEXT: mul a1, a1, a2 | ||
| ; RV32IM-NEXT: add a0, a1, a0 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: muliadd: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: qc.muliadd a0, a1, 165 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: muliadd: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: qc.muliadd a0, a1, 165 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, 165 | ||
| %add = add nsw i32 %mul, %a | ||
| ret i32 %add | ||
| } | ||
| 
     | 
||
| define dso_local i32 @muliadd_neg(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: muliadd_neg: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: li a2, -165 | ||
| ; RV32IM-NEXT: mul a1, a1, a2 | ||
| ; RV32IM-NEXT: add a0, a1, a0 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: muliadd_neg: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: qc.muliadd a0, a1, -165 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: muliadd_neg: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: qc.muliadd a0, a1, -165 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, -165 | ||
| %add = add nsw i32 %mul, %a | ||
| ret i32 %add | ||
| } | ||
| 
     | 
||
| define dso_local i32 @pow2immplus1(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: pow2immplus1: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: slli a2, a1, 5 | ||
| ; RV32IM-NEXT: add a0, a1, a0 | ||
| ; RV32IM-NEXT: add a0, a2, a0 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: pow2immplus1: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: qc.muliadd a0, a1, 33 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: pow2immplus1: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: qc.muliadd a0, a1, 33 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, 33 | ||
| %add = add nsw i32 %mul, %a | ||
| ret i32 %add | ||
| } | ||
| 
     | 
||
| define dso_local i32 @gtsimm12(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: gtsimm12: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: lui a2, 1 | ||
| ; RV32IM-NEXT: addi a2, a2, 477 | ||
| ; RV32IM-NEXT: mul a1, a1, a2 | ||
| ; RV32IM-NEXT: add a0, a1, a0 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: gtsimm12: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: lui a2, 1 | ||
| ; RV32IMXQCIAC-NEXT: addi a2, a2, 477 | ||
| ; RV32IMXQCIAC-NEXT: mul a1, a1, a2 | ||
| ; RV32IMXQCIAC-NEXT: add a0, a0, a1 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: gtsimm12: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: lui a2, 1 | ||
| ; RV32IZBAMXQCIAC-NEXT: addi a2, a2, 477 | ||
| ; RV32IZBAMXQCIAC-NEXT: mul a1, a1, a2 | ||
| ; RV32IZBAMXQCIAC-NEXT: add a0, a0, a1 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, 4573 | ||
| %add = add nsw i32 %mul, %a | ||
| ret i32 %add | ||
| } | ||
| 
     | 
||
| ; NOTE: This will become qc.shladd once support is added | ||
| define dso_local i32 @pow2(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: pow2: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: slli a1, a1, 5 | ||
| ; RV32IM-NEXT: add a0, a1, a0 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: pow2: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: slli a1, a1, 5 | ||
| ; RV32IMXQCIAC-NEXT: add a0, a0, a1 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: pow2: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: slli a1, a1, 5 | ||
| ; RV32IZBAMXQCIAC-NEXT: add a0, a0, a1 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, 32 | ||
| %add = add nsw i32 %mul, %a | ||
| ret i32 %add | ||
| } | ||
| 
     | 
||
| define dso_local i32 @shxadd(i32 %a, i32 %b) local_unnamed_addr #0 { | ||
| ; RV32IM-LABEL: shxadd: | ||
| ; RV32IM: # %bb.0: # %entry | ||
| ; RV32IM-NEXT: slli a1, a1, 1 | ||
| ; RV32IM-NEXT: add a0, a1, a0 | ||
| ; RV32IM-NEXT: ret | ||
| ; | ||
| ; RV32IMXQCIAC-LABEL: shxadd: | ||
| ; RV32IMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IMXQCIAC-NEXT: slli a1, a1, 1 | ||
| ; RV32IMXQCIAC-NEXT: add a0, a0, a1 | ||
| ; RV32IMXQCIAC-NEXT: ret | ||
| ; | ||
| ; RV32IZBAMXQCIAC-LABEL: shxadd: | ||
| ; RV32IZBAMXQCIAC: # %bb.0: # %entry | ||
| ; RV32IZBAMXQCIAC-NEXT: sh1add a0, a1, a0 | ||
| ; RV32IZBAMXQCIAC-NEXT: ret | ||
| entry: | ||
| %mul = mul nsw i32 %b, 2 | ||
| %add = add nsw i32 %mul, %a | ||
| ret i32 %add | ||
| } | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.