From: nemet Date: Thu, 9 Jul 2009 05:43:56 +0000 (+0000) Subject: * simplify-rtx.c (simplify_binary_operation_1) : Transform (and X-Git-Tag: upstream/4.9.2~34976 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85ece28d613b552bc84ca915ea018dde41c0ac02;p=platform%2Fupstream%2Flinaro-gcc.git * simplify-rtx.c (simplify_binary_operation_1) : Transform (and (truncate)) into (truncate (and)). testsuite/ * gcc.target/mips/truncate-5.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149402 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4007a66..0347c24 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2009-07-08 Adam Nemet + * simplify-rtx.c (simplify_binary_operation_1) : Transform (and + (truncate)) into (truncate (and)). + +2009-07-08 Adam Nemet + * combine.c (make_extraction): Check TRULY_NOOP_TRUNCATION before creating LHS paradoxical subregs. Fix surrounding returns to use NULL_RTX rather than 0. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 782d717..ff69068 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2336,6 +2336,18 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, return simplify_gen_unary (ZERO_EXTEND, mode, tem, imode); } + /* Transform (and (truncate X) C) into (truncate (and X C)). This way + we might be able to further simplify the AND with X and potentially + remove the truncation altogether. */ + if (GET_CODE (op0) == TRUNCATE && CONST_INT_P (trueop1)) + { + rtx x = XEXP (op0, 0); + enum machine_mode xmode = GET_MODE (x); + tem = simplify_gen_binary (AND, xmode, x, + gen_int_mode (INTVAL (trueop1), xmode)); + return simplify_gen_unary (TRUNCATE, mode, tem, xmode); + } + /* Canonicalize (A | C1) & C2 as (A & C2) | (C1 & C2). */ if (GET_CODE (op0) == IOR && CONST_INT_P (trueop1) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7258507..3dcfad3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,9 +1,13 @@ +2009-07-08 Adam Nemet + + * gcc.target/mips/truncate-5.c: New test. + 2009-07-08 Jerry DeLisle PR libfortran/40330 PR libfortran/40662 * gfortran.dg/fmt_cache_1.f: New test. - + 2009-07-08 Tobias Burnus PR fortran/40675 @@ -24,7 +28,7 @@ * gfortran.dg/proc_ptr_21.f90: New test. 2009-07-08 Manuel López-Ibáñez - + PR c++/31246 * g++.dg/warn/pr31246.C: New. * g++.dg/warn/pr31246-2.C: New. diff --git a/gcc/testsuite/gcc.target/mips/truncate-5.c b/gcc/testsuite/gcc.target/mips/truncate-5.c new file mode 100644 index 0000000..046ef80 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/truncate-5.c @@ -0,0 +1,14 @@ +/* If we AND in DI mode (i.e. replace the order of TRUNCATE and AND) then we + can remove the TRUNCATE. */ +/* { dg-options "-O -mgp64" } */ +/* { dg-final { scan-assembler-not "\tsll\t\[^\n\]*,0" } } */ + +struct s +{ + unsigned a:5; +}; + +f (struct s *s, unsigned long long a) +{ + s->a = a & 0x3; +}