[PATCH] __builtin_clz ICE on XScale

Adam Nemet anemet@Lnxw.COM
Thu Apr 25 23:26:00 GMT 2002


Hi,

On ARM with -mcpu=xscale -mthumb, the following testcase gives an
ICE.

f (int i, int j)
{
  i = __builtin_clz (j);
}

/tmp/x.c:4: unrecognizable insn:
(insn 26 25 30 (set (reg:SI 40)
        (unspec:SI[ 
                (reg:SI 39)
            ]  5)) -1 (nil)
    (expr_list:REG_DEAD (reg:SI 39)
        (nil)))
/tmp/x.c:4: Internal compiler error in extract_insn, at recog.c:2133

Apparently the built-in __builtin_clz is defined (and expanded) for
archv5 but then the insn is only recognized for TARGET_ARM.  This
small patch fixes this.  Please also apply the fix if accepted.

2002-04-25  Adam Nemet  <anemet@lnxw.com>

	* config/arm/arm.c (arm_init_builtins): Disable __builtin_clz when
	emitting Thumb code.

*** arm.c	2 Apr 2002 16:44:39 -0000	1.205
--- arm.c	26 Apr 2002 06:02:50 -0000
*************** arm_init_builtins ()
*** 9316,9322 ****
      = build_function_type (integer_type_node, int_endlink);
  
    /* Initialize arm V5 builtins.  */
!   if (arm_arch5)
      def_builtin ("__builtin_clz", int_ftype_int, ARM_BUILTIN_CLZ);
  }
  
--- 9316,9322 ----
      = build_function_type (integer_type_node, int_endlink);
  
    /* Initialize arm V5 builtins.  */
!   if (arm_arch5 && ! thumb_code)
      def_builtin ("__builtin_clz", int_ftype_int, ARM_BUILTIN_CLZ);
  }



More information about the Gcc-patches mailing list