This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/71460] Copying structs can trap (on x86-32) due to SNaN to QNaN


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71460

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #6)
> (In reply to UroÅ Bizjak from comment #5)
> > Following patch fixes the failure:
> > 
> > --cut here--
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index b807a9a..4526c7d 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -10310,10 +10310,8 @@ ix86_promote_function_mode (const_tree type,
> > machine_mode mode,
> >  static bool
> >  ix86_member_type_forces_blk (const_tree field, machine_mode mode)
> >  {
> > -  /* Union with XFmode must be in BLKmode.  */
> > -  return (mode == XFmode
> > -         && (TREE_CODE (DECL_FIELD_CONTEXT (field)) == UNION_TYPE
> > -             || TREE_CODE (DECL_FIELD_CONTEXT (field)) == QUAL_UNION_TYPE));
> > +  return (IS_STACK_MODE (mode) && flag_signaling_nans
> > +         && RECORD_OR_UNION_TYPE_P (DECL_FIELD_CONTEXT (field)));
> >  }
> >  
> >  rtx
> > --cut here--
> > 
> > Patch was tested with various -mfpmath=... compile flags. IMO, we don't need
> > BLKmode when we copy the value using SSE registers (and the test indeed does
> > not fail with -mfpmath=sse), and we still can copy XFmode using x87 regs
> > without -fsignalling-nans.
> > 
> > Richi, Joseph - does the new condition look OK to you?
> 
> Looks good to me.

Oh - I hope TYPE_MODE does not affect the ABI here ;)  You might want to
double-check that (struct-layout tests plus call ABI)

> Btw, the mentioned SRA issue probably still exists for full scalarization
> and re-mat for a call.  SRA should probably check member_type_forces_blk
> as well before creating full scalarization accesses.  Would be nice to
> have a testcase for the SRA case as well.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]