re PR middle-end/40692 (Endless recursion between fold_ternary and fold_cond_expr_with_comparison)

PR middle-end/40692
	* fold-const.c (fold_cond_expr_with_comparison): Don't replace
	arg1 with arg01 if arg1 is already INTEGER_CST.

	* gcc.c-torture/compile/pr40692.c: New test.

From-SVN: r149418
This commit is contained in:
Jakub Jelinek 2009-07-09 13:19:22 +02:00 committed by Jakub Jelinek
parent d175a2fa7c
commit b9da76de89
4 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-07-09 Jakub Jelinek <jakub@redhat.com>
PR middle-end/40692
* fold-const.c (fold_cond_expr_with_comparison): Don't replace
arg1 with arg01 if arg1 is already INTEGER_CST.
2009-07-08 Adam Nemet <anemet@caviumnetworks.com>
* simplify-rtx.c (simplify_binary_operation_1) <AND>: Transform (and

View File

@ -5303,6 +5303,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
switch (comp_code)
{
case EQ_EXPR:
if (TREE_CODE (arg1) == INTEGER_CST)
break;
/* We can replace A with C1 in this case. */
arg1 = fold_convert (type, arg01);
return fold_build3 (COND_EXPR, type, arg0, arg1, arg2);

View File

@ -1,3 +1,8 @@
2009-07-09 Jakub Jelinek <jakub@redhat.com>
PR middle-end/40692
* gcc.c-torture/compile/pr40692.c: New test.
2009-07-09 Tobias Burnus <burnus@net-b.de>
PR fortran/40604

View File

@ -0,0 +1,15 @@
/* PR middle-end/40692 */
#define M1(x) (((x) & 0x00000002) ? 0x2 : ((x) & 0x1))
#define M2(x) (((x) & 0x0000000c) ? M1 ((x) >> 2) << 2 : M1 (x))
#define M3(x) (((x) & 0x000000f0) ? M2 ((x) >> 4) << 4 : M2 (x))
#define M4(x) (((x) & 0x0000ff00) ? M3 ((x) >> 8) << 8 : M3 (x))
#define M5(x) (((x) & 0xffff0000) ? M4 ((x) >> 16) << 16 : M4 (x))
struct A { char e; char f; };
long
foo (void)
{
return M5 (4096UL - (long) &((struct A *) 0)->f);
}