This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR19331: Improve RTL bit-field simplification (take 2)
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Richard Henderson <rth at redhat dot com>
- Date: Sun, 6 Feb 2005 06:53:51 -0700 (MST)
- Subject: [PATCH] PR19331: Improve RTL bit-field simplification (take 2)
This revised patch takes incorporates feedback from both Richard Henderson
and Paolo Bonzini. The first change is that this patch now checks that
cmp_mode isn't VOIDmode, and the second is that it now uses nonzero_bits
rather than test for only zero_extracts of a single bit.
The following patch has been retested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures. I then recheck manually
that this improves the code we generate for the PR19331 testcase. That
PR still isn't resolved by this change, but this gets us a step closer.
Ok for mainline?
2005-02-06 Roger Sayle <roger@eyesopen.com>
Andrew Pinski <pinskia@physics.uc.edu>
Paolo Bonzini <paolo.bonzini@lu.unisi.ch>
* simplify-rtx.c (simplify_relational_operation_1): Simplify
(ne:SI (zero_extract:SI FOO (const_int 1) BAR) (const_int 0))
into just (zero_extract:SI FOO (const_int 1) BAR).
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.223
diff -c -3 -p -r1.223 simplify-rtx.c
*** simplify-rtx.c 21 Jan 2005 17:54:26 -0000 1.223
--- simplify-rtx.c 6 Feb 2005 15:14:20 -0000
*************** simplify_relational_operation_1 (enum rt
*** 2876,2881 ****
--- 2876,2893 ----
return simplify_gen_relational (code, mode, cmp_mode, x, c);
}
+ /* (ne:SI (zero_extract:SI FOO (const_int 1) BAR) (const_int 0))) is
+ the same as (zero_extract:SI FOO (const_int 1) BAR). */
+ if (code == NE
+ && op1 == const0_rtx
+ && GET_MODE_CLASS (mode) == MODE_INT
+ && cmp_mode != VOIDmode
+ && nonzero_bits (op0, cmp_mode) == 1
+ && STORE_FLAG_VALUE == 1)
+ return GET_MODE_SIZE (mode) > GET_MODE_SIZE (cmp_mode)
+ ? simplify_gen_unary (ZERO_EXTEND, mode, op0, cmp_mode)
+ : gen_lowpart (mode, op0);
+
return NULL_RTX;
}
Roger
--