From 146aef0b3998e76f16c3ab8255d1caa3dcb4c870 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 21 Jun 2011 18:25:57 +0200 Subject: re PR middle-end/49489 (gcc.c-torture/execute/builtin-bitops-1.c fails on x86_64-linux) PR middle-end/49489 * builtins.c (expand_builtin_unop): Call expand_unop with 0 as unsignedp argument instead of 1 for clrsb_optab. (fold_builtin_bitop): Fix masking for width > HOST_BITS_PER_WIDE_INT and < 2 * HOST_BITS_PER_WIDE_INT. Optimize BUILT_IN_CLRSB*. (fold_builtin_1): Call fold_builtin_binop for BUILT_IN_CLRSB*. * optabs.c (widen_leading): Call widen_operand and expand_unop with 0 as unsignedp argument instead of 1 for clrsb_optab. (expand_unop): Subtract difference of mode sizes also for clrsb_optab. From-SVN: r175265 --- gcc/optabs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'gcc/optabs.c') diff --git a/gcc/optabs.c b/gcc/optabs.c index 7448450..969d5cf 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -1,7 +1,7 @@ /* Expand the basic unary and binary arithmetic operations, for GNU compiler. Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, + 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -2350,8 +2350,10 @@ widen_leading (enum machine_mode mode, rtx op0, rtx target, optab unoptab) if (target == 0) target = gen_reg_rtx (mode); - xop0 = widen_operand (op0, wider_mode, mode, true, false); - temp = expand_unop (wider_mode, unoptab, xop0, NULL_RTX, true); + xop0 = widen_operand (op0, wider_mode, mode, + unoptab != clrsb_optab, false); + temp = expand_unop (wider_mode, unoptab, xop0, NULL_RTX, + unoptab != clrsb_optab); if (temp != 0) temp = expand_binop (wider_mode, sub_optab, temp, GEN_INT (GET_MODE_BITSIZE (wider_mode) @@ -3075,8 +3077,9 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, unsignedp); /* If we are generating clz using wider mode, adjust the - result. */ - if (unoptab == clz_optab && temp != 0) + result. Similarly for clrsb. */ + if ((unoptab == clz_optab || unoptab == clrsb_optab) + && temp != 0) temp = expand_binop (wider_mode, sub_optab, temp, GEN_INT (GET_MODE_BITSIZE (wider_mode) - GET_MODE_BITSIZE (mode)), -- cgit v1.1