- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
[AArch64][GlobalISel] Fix lowering of i64->f32 itofp. #132703
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 all commits
      Commits
    
    
  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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  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.
Why is this under lower and not narrow scalar?
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.
Yeah I was wondering which was better. It felt more like a lower than a generic narrow. If a target wanted a single fptrunc (because they had an instruction for it), then they wouldn't want it to be split. So they would opt for the narrow. As far as I understand the narrows don't make extra legalization queries, there isn't a way to communicate two different types to them, and the alternative of a target hook doesn't sound the best. Maybe I'm missing something about how this should work.
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.
The promote has a type parameter that tells the new type to use. I don't see what information is missing?
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.
AFAIR: We are trying to lower a
vNi64->vNf16 uitofp, without scalarizing. For example av4i64->v4f16 uitofpturns intoSo a
v4f16 fptrunc(v4f32 fptrunc(v4f64 uitofp(v4i64)))(where the v4i64 is two vectors). If we initially say "widen type0 to f64" we getv4f16 fptrunc(v4f64 uitofp(v4i64))and thev4f16 fptrunc(v4f64needs to scalarize. If we say "widen type0 to f32" we getv4f16 fptrunc(v4f32 uitofp(v4i64))and thev4f32 uitofp(v4i64needs to scalarize (the point of this patch). That is what I meant by "there isn't a way to communicate two different types", you can't give it "widen to f64 via f32 please".Note: for scalar we want it to become
f16 fptrunc(f64 uitofp(i64))because we have an instruction for f64->f16 fptrunc. We don't want it to become two fptruncs.(Whilst thinking about this, I wondered if we could lower to
uqxtn+uqxtn2+scvtf+fcvtnfor fp16 instead, but that would involve a TRUNCATE_USAT_U that we don't have for globalisel yet).Currently we have it that lower means legalize via two steps, widen means lower directly, which might not be the best but fits into "lower does something different". What was the concrete suggestion for how this should work?
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.
If the answer is "Check that the G_FPTRUNC is not legal in widenScalar for G_UITOFP" then I can give that a go, we just don't call other legalization actions in most of LegalizerHelper at the moment. The vector types will need to split even if the vector types are not legal (wider vectors etc).