- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
[DAG] Fold rem(rem(A, BCst), Op1Cst) -> rem(A, Op1Cst) #159517
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 2 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4bda9d4
              
                [DAG] Fold urem(urem(A, BCst), Op1Cst) -> urem(A, Op1Cst)
              
              
                kper e953dbe
              
                Removed unused header from debugging
              
              
                kper 220de86
              
                Fixed typo
              
              
                kper 0dc64ea
              
                [DAG] Fold srem(srem(A, BCst), Op1Cst) -> srem(A, Op1Cst)
              
              
                kper 1ac624d
              
                Addressed feedback
              
              
                kper 75c8465
              
                Merge branch 'main' into 157370-dag-combine
              
              
                RKSimon 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck -check-prefixes=CHECK,RV32I %s | ||
| ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck -check-prefixes=CHECK,RV64I %s | ||
|  | ||
| define i32 @fold_urem_constants(i32 %v0) { | ||
| ; RV32I-LABEL: fold_urem_constants: | ||
| ; RV32I: # %bb.0: | ||
| ; RV32I-NEXT: li a1, 5 | ||
| ; RV32I-NEXT: tail __umodsi3 | ||
| ; | ||
| ; RV64I-LABEL: fold_urem_constants: | ||
| ; RV64I: # %bb.0: | ||
| ; RV64I-NEXT: addi sp, sp, -16 | ||
| ; RV64I-NEXT: .cfi_def_cfa_offset 16 | ||
| ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill | ||
| ; RV64I-NEXT: .cfi_offset ra, -8 | ||
| ; RV64I-NEXT: slli a0, a0, 32 | ||
| ; RV64I-NEXT: srli a0, a0, 32 | ||
| ; RV64I-NEXT: li a1, 5 | ||
| ; RV64I-NEXT: call __umoddi3 | ||
| ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload | ||
| ; RV64I-NEXT: .cfi_restore ra | ||
| ; RV64I-NEXT: addi sp, sp, 16 | ||
| ; RV64I-NEXT: .cfi_def_cfa_offset 0 | ||
| ; RV64I-NEXT: ret | ||
| %v1 = urem i32 %v0, 25 | ||
| %v2 = urem i32 %v1, 5 | ||
| ret i32 %v2 | ||
| } | ||
|  | ||
| define i32 @dont_test_fold_urem_constants(i32 %v0) { | ||
| ; RV32I-LABEL: dont_test_fold_urem_constants: | ||
| ; RV32I: # %bb.0: | ||
| ; RV32I-NEXT: addi sp, sp, -16 | ||
| ; RV32I-NEXT: .cfi_def_cfa_offset 16 | ||
| ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill | ||
| ; RV32I-NEXT: .cfi_offset ra, -4 | ||
| ; RV32I-NEXT: li a1, 25 | ||
| ; RV32I-NEXT: call __umodsi3 | ||
| ; RV32I-NEXT: li a1, 3 | ||
| ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload | ||
| ; RV32I-NEXT: .cfi_restore ra | ||
| ; RV32I-NEXT: addi sp, sp, 16 | ||
| ; RV32I-NEXT: .cfi_def_cfa_offset 0 | ||
| ; RV32I-NEXT: tail __umodsi3 | ||
| ; | ||
| ; RV64I-LABEL: dont_test_fold_urem_constants: | ||
| ; RV64I: # %bb.0: | ||
| ; RV64I-NEXT: addi sp, sp, -16 | ||
| ; RV64I-NEXT: .cfi_def_cfa_offset 16 | ||
| ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill | ||
| ; RV64I-NEXT: .cfi_offset ra, -8 | ||
| ; RV64I-NEXT: slli a0, a0, 32 | ||
| ; RV64I-NEXT: srli a0, a0, 32 | ||
| ; RV64I-NEXT: li a1, 25 | ||
| ; RV64I-NEXT: call __umoddi3 | ||
| ; RV64I-NEXT: li a1, 3 | ||
| ; RV64I-NEXT: call __umoddi3 | ||
| ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload | ||
| ; RV64I-NEXT: .cfi_restore ra | ||
| ; RV64I-NEXT: addi sp, sp, 16 | ||
| ; RV64I-NEXT: .cfi_def_cfa_offset 0 | ||
| ; RV64I-NEXT: ret | ||
| %v1 = urem i32 %v0, 25 | ||
| %v2 = urem i32 %v1, 3 | ||
| ret i32 %v2 | ||
| } | ||
| ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: | ||
| ; CHECK: {{.*}} | 
  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.
  
    
  
    
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.
Nit: call it
BCstto match the comment?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.
Thanks, it was a typo :)