* Bug 47790 - [4.5/4.6/4.7 Regression] optimize_bitfield_assignment_op no longer works in 4.5.x
@ 2011-03-18 14:01 Jeff Law
0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2011-03-18 14:01 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 969 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andrew included a patch in this PR to make
optimize_bitfield_assignment_op work again. I've fixed a couple
indention problems and added a couple comments.
Bootstrapped and regression tested on x86_64-unknown-linux-gnu. Applied
to trunk.
Interestingly enough, it clearly helps the testcase referenced in the
PR, but doesn't help GCC itself or the runtime libraries.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJNg2WxAAoJEBRtltQi2kC7zBUIAKqguCLpaXKfsQ4LnUfBlnvS
7f4ortxtl30UoIIAVhMD1kaVusdCYPAGBPd4nfvj5QWdf3Ka2h+wrNevRZdG9jqQ
kmcaDt39khLrzagau3EmgxfG3FhjTfLQME8b+4D07Hj3FuYlxepUuv0wQ9phJZKI
Q6Ra33peqlG5q9ywSOoFtDWeOPdhLF/cHt4N6iSPhD4kQEqpo8KyHe3MSON+0WF/
Y1Hu41ASYmNHnjemjUJojbLaVfGkgdJsIBi90TmwNcv1yCEeYpiDQCzdsP5aWpaZ
lv9yVWcuTiUux2uzgNhrHJWBOMAcsJ0i8Wlo5IhnHAKVTg6gwa+7+yYd1c/05ao=
=9x8U
-----END PGP SIGNATURE-----
[-- Attachment #2: P --]
[-- Type: text/plain, Size: 3563 bytes --]
PR middle-end/47790
* expr.c (optimize_bitfield_assignment_op): Revamp to work
again after expansion changes.
Index: expr.c
===================================================================
*** expr.c (revision 171074)
--- expr.c (working copy)
*************** optimize_bitfield_assignment_op (unsigne
*** 3974,3979 ****
--- 3974,3981 ----
tree op0, op1;
rtx value, result;
optab binop;
+ gimple srcstmt;
+ enum tree_code code;
if (mode1 != VOIDmode
|| bitsize >= BITS_PER_WORD
*************** optimize_bitfield_assignment_op (unsigne
*** 3983,3995 ****
return false;
STRIP_NOPS (src);
! if (!BINARY_CLASS_P (src)
! || TREE_CODE (TREE_TYPE (src)) != INTEGER_TYPE)
return false;
! op0 = TREE_OPERAND (src, 0);
! op1 = TREE_OPERAND (src, 1);
! STRIP_NOPS (op0);
if (!operand_equal_p (to, op0, 0))
return false;
--- 3985,4021 ----
return false;
STRIP_NOPS (src);
! if (TREE_CODE (src) != SSA_NAME)
! return false;
! if (TREE_CODE (TREE_TYPE (src)) != INTEGER_TYPE)
! return false;
!
! srcstmt = get_gimple_for_ssa_name (src);
! if (!srcstmt
! || TREE_CODE_CLASS (gimple_assign_rhs_code (srcstmt)) != tcc_binary)
return false;
! code = gimple_assign_rhs_code (srcstmt);
!
! op0 = gimple_assign_rhs1 (srcstmt);
!
! /* If OP0 is an SSA_NAME, then we want to walk the use-def chain
! to find its initialization. Hopefully the initialization will
! be from a bitfield load. */
! if (TREE_CODE (op0) == SSA_NAME)
! {
! gimple op0stmt = get_gimple_for_ssa_name (op0);
!
! /* We want to eventually have OP0 be the same as TO, which
! should be a bitfield. */
! if (!op0stmt
! || !is_gimple_assign (op0stmt)
! || gimple_assign_rhs_code (op0stmt) != TREE_CODE (to))
! return false;
! op0 = gimple_assign_rhs1 (op0stmt);
! }
!
! op1 = gimple_assign_rhs2 (srcstmt);
if (!operand_equal_p (to, op0, 0))
return false;
*************** optimize_bitfield_assignment_op (unsigne
*** 4026,4032 ****
if (BYTES_BIG_ENDIAN)
bitpos = str_bitsize - bitpos - bitsize;
! switch (TREE_CODE (src))
{
case PLUS_EXPR:
case MINUS_EXPR:
--- 4052,4058 ----
if (BYTES_BIG_ENDIAN)
bitpos = str_bitsize - bitpos - bitsize;
! switch (code)
{
case PLUS_EXPR:
case MINUS_EXPR:
*************** optimize_bitfield_assignment_op (unsigne
*** 4054,4060 ****
set_mem_expr (str_rtx, 0);
}
! binop = TREE_CODE (src) == PLUS_EXPR ? add_optab : sub_optab;
if (bitsize == 1 && bitpos + bitsize != str_bitsize)
{
value = expand_and (str_mode, value, const1_rtx, NULL);
--- 4080,4086 ----
set_mem_expr (str_rtx, 0);
}
! binop = code == PLUS_EXPR ? add_optab : sub_optab;
if (bitsize == 1 && bitpos + bitsize != str_bitsize)
{
value = expand_and (str_mode, value, const1_rtx, NULL);
*************** optimize_bitfield_assignment_op (unsigne
*** 4087,4093 ****
set_mem_expr (str_rtx, 0);
}
! binop = TREE_CODE (src) == BIT_IOR_EXPR ? ior_optab : xor_optab;
if (bitpos + bitsize != GET_MODE_BITSIZE (GET_MODE (str_rtx)))
{
rtx mask = GEN_INT (((unsigned HOST_WIDE_INT) 1 << bitsize)
--- 4113,4119 ----
set_mem_expr (str_rtx, 0);
}
! binop = code == BIT_IOR_EXPR ? ior_optab : xor_optab;
if (bitpos + bitsize != GET_MODE_BITSIZE (GET_MODE (str_rtx)))
{
rtx mask = GEN_INT (((unsigned HOST_WIDE_INT) 1 << bitsize)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-18 14:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 14:01 Bug 47790 - [4.5/4.6/4.7 Regression] optimize_bitfield_assignment_op no longer works in 4.5.x Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).