Here is a slightly modified version of bf64-1.c with print statments:

struct tmp
{
  long long int pad : 12;
  long long int field : 52;
};

struct tmp2
{
  long long int field : 52;
  long long int pad : 12;
};

struct tmp  sub  (struct tmp  xtmp);
struct tmp2 sub2 (struct tmp2 xtmp2);

struct tmp
sub (struct tmp xtmp)
{
  xtmp.field |= 0x0008765412345678LL;
  return xtmp;
}

struct tmp2
sub2 (struct tmp2 xtmp2)
{
  xtmp2.field |= 0x0008765412345678LL;
  return xtmp2;
}

main()
{
  struct tmp xtmp = {0x123, 0xFFF000FFF000FLL};
  struct tmp2 xtmp2 = {0xFFF000FFF000FLL, 0x123};

  xtmp = sub (xtmp);
  xtmp2 = sub2 (xtmp2);
  printf("%lld\n", xtmp.pad);
  printf("%lld\n", xtmp.field);
  printf("%lld\n", xtmp2.pad);
  printf("%lld\n", xtmp2.field);
  exit (0);
}

With -O0 it prints:

291
-738197547393
291
-738197547393

At -O1 it prints:

291
1479942473249059
291
-738197547393


This bug happens on IA64 HP-UX (with -O1 and in 32 or 64 bit mode) but not on
IA64 Linux.  I tracked the start of failure to the following patch but was
unable to figure out what the exact problem is.

2004-09-03  Richard Henderson  <[EMAIL PROTECTED]>

        PR middle-end/9997
        * cfgexpand.c (LOCAL_ALIGNMENT): Provide default.
        (STACK_ALIGNMENT_NEEDED, FRAME_GROWS_DOWNWARD): Likewise.
        (struct stack_var, EOC, stack_vars, stack_vars_alloc, stack_vars_num,
        stack_vars_sorted, stack_vars_conflict, stack_vars_conflict_alloc,
        frame_phase, get_decl_align_unit, add_stack_var, triangular_index,
        resize_stack_vars_conflict, add_stack_var_conflict,
        stack_var_conflict_p, add_alias_set_conflicts, stack_var_size_cmp,
        union_stack_vars, partition_stack_vars, dump_stack_var_partition,
        expand_one_stack_var_at, expand_stack_vars, expand_one_stack_var,
        expand_one_static_var, expand_one_hard_reg_var,
        expand_one_register_var, expand_one_error_var, defer_stack_allocation,
        expand_one_var, expand_used_vars_for_block, clear_tree_used): New.
        (expand_used_vars): Rewrite.
        * Makefile.in (cfgexpand.o): Update dependencies.

-- 
           Summary: bad code generated with gcc.c-torture/execute/bf64-1.c
                    at -O1
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sje at cup dot hp dot com
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: ia64-hp-hpux11.20


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19454

Reply via email to