https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
It seems that the libgcc functions for SImode are present (at least on x86_64),
so sth like
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c (revision 212970)
+++ gcc/optabs.c (working copy)
@@ -5559,13 +5559,17 @@ gen_int_libfunc (optab optable, const ch
enum machine_mode mode)
{
int maxsize = 2 * BITS_PER_WORD;
+ int minsize = BITS_PER_WORD;
if (GET_MODE_CLASS (mode) != MODE_INT)
return;
if (maxsize < LONG_LONG_TYPE_SIZE)
maxsize = LONG_LONG_TYPE_SIZE;
- if (GET_MODE_CLASS (mode) != MODE_INT
- || GET_MODE_BITSIZE (mode) < BITS_PER_WORD
+ if (minsize > INT_TYPE_SIZE
+ && (trapv_binoptab_p (optable)
+ || trapv_unoptab_p (optable)))
+ minsize = INT_TYPE_SIZE;
+ if (GET_MODE_BITSIZE (mode) < minsize
|| GET_MODE_BITSIZE (mode) > maxsize)
return;
gen_libfunc (optable, opname, suffix, mode);
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 212970)
+++ gcc/expr.c (working copy)
@@ -9212,7 +9212,9 @@ expand_expr_real_2 (sepops ops, rtx targ
if (modifier == EXPAND_STACK_PARM)
target = 0;
temp = expand_binop (mode, this_optab, op0, op1, target,
- unsignedp, OPTAB_LIB_WIDEN);
+ unsignedp,
+ trapv_binoptab_p (this_optab)
+ ? OPTAB_LIB : OPTAB_LIB_WIDEN);
gcc_assert (temp);
/* Bitwise operations do not need bitfield reduction as we expect their
operands being properly truncated. */
makes the testcase pass.