ARM: Fix the CLZ instruction.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 27 Jul 2009 07:52:59 +0000 (00:52 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 27 Jul 2009 07:52:59 +0000 (00:52 -0700)
src/arch/arm/isa/decoder.isa

index f43395c19bde91bd91fc23088c0c464eb0c43dc9..046e529507ef77523664bed8cac39c81e46ec1db 100644 (file)
@@ -113,8 +113,7 @@ format DataOp {
                 0x1: decode OPCODE {
                     0x9: BranchExchange::bx({{ }});
                     0xb: PredOp::clz({{
-                        unsigned lsb = findLsbSet(Rm);
-                        Rd = (lsb > 31) ? 32 : lsb;
+                        Rd = ((Rm == 0) ? 32 : (31 - findMsbSet(Rm)));
                     }});
                 }
                 0x2: decode OPCODE {