diff mbox

Handle CLRSB in nonzero_bits1

Message ID 20110823175214.GM2687@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Aug. 23, 2011, 5:52 p.m. UTC
Hi!

While looking at PR50168, I've noticed that CLRSB isn't handled
in nonzero_bits1 (while FFS/POPCOUNT/PARITY/CLZ/CTZ are).
It means that combine can't optimize say clrsb insn followed by
zero or sign extension of the result.

Fixed thusly, ok for trunk?

2011-08-23  Jakub Jelinek  <jakub@redhat.com>

	* rtlanal.c (nonzero_bits1): Handle CLRSB.


	Jakub

Comments

Richard Henderson Aug. 23, 2011, 6:05 p.m. UTC | #1
On 08/23/2011 10:52 AM, Jakub Jelinek wrote:
> 2011-08-23  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* rtlanal.c (nonzero_bits1): Handle CLRSB.

Ok.


r~
diff mbox

Patch

--- gcc/rtlanal.c.jj	2011-08-22 08:17:07.000000000 +0200
+++ gcc/rtlanal.c	2011-08-23 19:46:13.000000000 +0200
@@ -1,7 +1,7 @@ 
 /* Analyze RTL 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.
 
@@ -4273,6 +4273,11 @@  nonzero_bits1 (const_rtx x, enum machine
 	nonzero = -1;
       break;
 
+    case CLRSB:
+      /* This is at most the number of bits in the mode minus 1.  */
+      nonzero = ((unsigned HOST_WIDE_INT) 1 << (floor_log2 (mode_width))) - 1;
+      break;
+
     case PARITY:
       nonzero = 1;
       break;