re PR middle-end/32244 (bit-field: optimization BUG)

2008-01-25  Richard Guenther  <rguenther@suse.de>

	PR middle-end/32244
	* expr.c (expand_expr_real_1): Reduce result of LSHIFT_EXPR
	to its bitfield precision if required.

	* gcc.c-torture/execute/pr32244-1.c: New testcase.

From-SVN: r131828
This commit is contained in:
Richard Guenther 2008-01-25 15:33:09 +00:00 committed by Richard Biener
parent c256730cef
commit dd3b33d773
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2008-01-25 Richard Guenther <rguenther@suse.de>
PR middle-end/32244
* expr.c (expand_expr_real_1): Reduce result of LSHIFT_EXPR
to its bitfield precision if required.
2008-01-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/33880

View File

@ -8920,8 +8920,11 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
target = 0;
op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget,
VOIDmode, EXPAND_NORMAL);
return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
temp = expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
unsignedp);
if (code == LSHIFT_EXPR)
temp = REDUCE_BIT_FIELD (temp);
return temp;
/* Could determine the answer when only additive constants differ. Also,
the addition of one can be handled by changing the condition. */

View File

@ -1,3 +1,8 @@
2008-01-25 Richard Guenther <rguenther@suse.de>
PR middle-end/32244
* gcc.c-torture/execute/pr32244-1.c: New testcase.
2008-01-25 Richard Guenther <rguenther@suse.de>
PR tree-optimization/34966

View File

@ -0,0 +1,20 @@
struct foo
{
unsigned long long b:40;
} x;
extern void abort (void);
void test1(unsigned long long res)
{
/* The shift is carried out in 40 bit precision. */
if (x.b<<32 != res)
abort ();
}
int main()
{
x.b = 0x0100;
test1(0);
return 0;
}