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 rtl-optimization/24930] New: Crash in combine


(in mainline)  compile the below with -O.  A patch follows which I'm fairly
sure is right, but I will not be able to run a test cycle until Nov 30.  I'll
do it then if nobody else has.

$ld/gcc/gccs.fsf.obj/gcc/xgcc -B $ld/gcc/gccs.fsf.obj/gcc/ -O 4347034.c
4347034.c: In function 'main':
4347034.c:5: warning: incompatible implicit declaration of built-in function
'printf'
4347034.c:17: warning: incompatible implicit declaration of built-in function
'printf'
4347034.c:19: internal compiler error: in do_SUBST, at combine.c:470

int
main(int argc, char** argv)
{
  if(argc == 1) {
    printf("Please provide a two char argument\n");
    return 0;
  }
  const char *buf = argv[1];

  unsigned int data = (((unsigned int) buf[0]) << 8) + (unsigned int) buf[1];
  if (data & 0x8000) {
    data &= 0x7fff ;
    data ^= 0x7fff ;
    data += 1 ;
    data *= -1 ;
  }
  printf("Data = %d\n", (int) data);
  return 0;
}


Index: combine.c
===================================================================
--- combine.c   (revision 107129)
+++ combine.c   (working copy)
@@ -3346,13 +3346,15 @@
          rtx dest = XEXP (SET_DEST (x), 0);
          enum machine_mode mode = GET_MODE (dest);
          unsigned HOST_WIDE_INT mask = ((HOST_WIDE_INT) 1 << len) - 1;
+         rtx or_mask;

          if (BITS_BIG_ENDIAN)
            pos = GET_MODE_BITSIZE (mode) - len - pos;

+         or_mask = GEN_INT (trunc_int_for_mode (src << pos, mode));
          if (src == mask)
            SUBST (SET_SRC (x),
-                  simplify_gen_binary (IOR, mode, dest, GEN_INT (src <<
pos)));
+                  simplify_gen_binary (IOR, mode, dest, or_mask));
          else
            {
              rtx negmask = gen_int_mode (~(mask << pos), mode);
@@ -3360,7 +3362,7 @@
                     simplify_gen_binary (IOR, mode,
                                          simplify_gen_binary (AND, mode,
                                                               dest, negmask),
-                                         GEN_INT (src << pos)));
+                                         or_mask));
            }

          SUBST (SET_DEST (x), dest);


-- 
           Summary: Crash in combine
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dalej at gcc dot gnu dot org
 GCC build triplet: same
  GCC host triplet: powerpc-apple-darwin
GCC target triplet: same


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


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