From 0b8495ae4558d0e96ef3f1cdb8333e820228f0a2 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 30 Mar 2005 20:59:21 +0000 Subject: [PATCH] Fix problem with calling powi* builtins. OKed by Richard Henderson. From-SVN: r97278 --- gcc/ChangeLog | 9 +++++++++ gcc/builtins.c | 12 ++++++++---- gcc/libgcc2.c | 6 ++++-- gcc/libgcc2.h | 10 ++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d20452dc32..384e48e8cdc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-03-30 Fariborz Jahanian + + * builtins.c (expand_builtin_powi): Fix mode of + 2nd argument to match int. + * libgcc2.h (__powisf2, __powidf2, __powixf2, __powitf2): Change + 2nd argument type to int. + * libgcc2.c: Change prototype of __powi* functions to use + int. + 2005-03-30 Dale Johannesen PR middle-end/19225 diff --git a/gcc/builtins.c b/gcc/builtins.c index 68b91c56772..fb044de52ac 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2380,6 +2380,7 @@ expand_builtin_powi (tree exp, rtx target, rtx subtarget) tree arg0, arg1; rtx op0, op1; enum machine_mode mode; + enum machine_mode mode2; if (! validate_arglist (arglist, REAL_TYPE, INTEGER_TYPE, VOID_TYPE)) return 0; @@ -2411,19 +2412,22 @@ expand_builtin_powi (tree exp, rtx target, rtx subtarget) /* Emit a libcall to libgcc. */ + /* Mode of the 2nd argument must match that of an int. */ + mode2 = mode_for_size (INT_TYPE_SIZE, MODE_INT, 0); + if (target == NULL_RTX) target = gen_reg_rtx (mode); op0 = expand_expr (arg0, subtarget, mode, 0); if (GET_MODE (op0) != mode) op0 = convert_to_mode (mode, op0, 0); - op1 = expand_expr (arg1, 0, word_mode, 0); - if (GET_MODE (op1) != word_mode) - op1 = convert_to_mode (word_mode, op1, 0); + op1 = expand_expr (arg1, 0, mode2, 0); + if (GET_MODE (op1) != mode2) + op1 = convert_to_mode (mode2, op1, 0); target = emit_library_call_value (powi_optab->handlers[(int) mode].libfunc, target, LCT_CONST_MAKE_BLOCK, mode, 2, - op0, mode, op1, word_mode); + op0, mode, op1, mode2); return target; } diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index c8f6e51b043..e1b2c45af2d 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -1538,10 +1538,12 @@ __fixunssfSI (SFtype a) # define NAME __powitf2 # endif +#undef int +#undef unsigned TYPE -NAME (TYPE x, Wtype m) +NAME (TYPE x, int m) { - UWtype n = m < 0 ? -m : m; + unsigned int n = m < 0 ? -m : m; TYPE y = n % 2 ? x : 1; while (n >>= 1) { diff --git a/gcc/libgcc2.h b/gcc/libgcc2.h index 11444ed9e45..cc4c13f7902 100644 --- a/gcc/libgcc2.h +++ b/gcc/libgcc2.h @@ -314,12 +314,13 @@ extern SItype __mulvsi3 (SItype, SItype); extern SItype __negvsi2 (SItype); #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */ +#undef int #if LIBGCC2_HAS_SF_MODE extern DWtype __fixsfdi (SFtype); extern SFtype __floatdisf (DWtype); extern UWtype __fixunssfSI (SFtype); extern DWtype __fixunssfDI (SFtype); -extern SFtype __powisf2 (SFtype, Wtype); +extern SFtype __powisf2 (SFtype, int); extern SCtype __divsc3 (SFtype, SFtype, SFtype, SFtype); extern SCtype __mulsc3 (SFtype, SFtype, SFtype, SFtype); #endif @@ -328,7 +329,7 @@ extern DWtype __fixdfdi (DFtype); extern DFtype __floatdidf (DWtype); extern UWtype __fixunsdfSI (DFtype); extern DWtype __fixunsdfDI (DFtype); -extern DFtype __powidf2 (DFtype, Wtype); +extern DFtype __powidf2 (DFtype, int); extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype); extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype); #endif @@ -338,7 +339,7 @@ extern DWtype __fixxfdi (XFtype); extern DWtype __fixunsxfDI (XFtype); extern XFtype __floatdixf (DWtype); extern UWtype __fixunsxfSI (XFtype); -extern XFtype __powixf2 (XFtype, Wtype); +extern XFtype __powixf2 (XFtype, int); extern XCtype __divxc3 (XFtype, XFtype, XFtype, XFtype); extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype); #endif @@ -347,10 +348,11 @@ extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype); extern DWtype __fixunstfDI (TFtype); extern DWtype __fixtfdi (TFtype); extern TFtype __floatditf (DWtype); -extern TFtype __powitf2 (TFtype, Wtype); +extern TFtype __powitf2 (TFtype, int); extern TCtype __divtc3 (TFtype, TFtype, TFtype, TFtype); extern TCtype __multc3 (TFtype, TFtype, TFtype, TFtype); #endif +#define int bogus_type /* DWstructs are pairs of Wtype values in the order determined by LIBGCC2_WORDS_BIG_ENDIAN. */ -- 2.30.2