re PR target/26961 (ICE simplify_subreg:3813)
PR target/26961 * fold-const.c (fold_ternary): When converting "A ? B : C" into either "A op B" or "A op C", we may need to convert A to the type of B and C. * gcc.dg/fold-cond-1.c: New test case. * gcc.dg/pr26961-1.c: Likewise. From-SVN: r113001
This commit is contained in:
parent
27b9964175
commit
726ac11ebd
@ -1,3 +1,9 @@
|
||||
2006-04-16 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR target/26961
|
||||
* fold-const.c (fold_ternary): When converting "A ? B : C" into either
|
||||
"A op B" or "A op C", we may need to convert A to the type of B and C.
|
||||
|
||||
2006-04-16 Adam Nemet <anemet@caviumnetworks.com>
|
||||
|
||||
* target.h (struct gcc_target): Add mode_rep_extended.
|
||||
|
@ -11073,7 +11073,9 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
|
||||
if (integer_zerop (op2)
|
||||
&& truth_value_p (TREE_CODE (arg0))
|
||||
&& truth_value_p (TREE_CODE (arg1)))
|
||||
return fold_build2 (TRUTH_ANDIF_EXPR, type, arg0, arg1);
|
||||
return fold_build2 (TRUTH_ANDIF_EXPR, type,
|
||||
fold_convert (type, arg0),
|
||||
arg1);
|
||||
|
||||
/* Convert A ? B : 1 into !A || B if A and B are truth values. */
|
||||
if (integer_onep (op2)
|
||||
@ -11083,7 +11085,9 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
|
||||
/* Only perform transformation if ARG0 is easily inverted. */
|
||||
tem = invert_truthvalue (arg0);
|
||||
if (TREE_CODE (tem) != TRUTH_NOT_EXPR)
|
||||
return fold_build2 (TRUTH_ORIF_EXPR, type, tem, arg1);
|
||||
return fold_build2 (TRUTH_ORIF_EXPR, type,
|
||||
fold_convert (type, tem),
|
||||
arg1);
|
||||
}
|
||||
|
||||
/* Convert A ? 0 : B into !A && B if A and B are truth values. */
|
||||
@ -11094,14 +11098,18 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
|
||||
/* Only perform transformation if ARG0 is easily inverted. */
|
||||
tem = invert_truthvalue (arg0);
|
||||
if (TREE_CODE (tem) != TRUTH_NOT_EXPR)
|
||||
return fold_build2 (TRUTH_ANDIF_EXPR, type, tem, op2);
|
||||
return fold_build2 (TRUTH_ANDIF_EXPR, type,
|
||||
fold_convert (type, tem),
|
||||
op2);
|
||||
}
|
||||
|
||||
/* Convert A ? 1 : B into A || B if A and B are truth values. */
|
||||
if (integer_onep (arg1)
|
||||
&& truth_value_p (TREE_CODE (arg0))
|
||||
&& truth_value_p (TREE_CODE (op2)))
|
||||
return fold_build2 (TRUTH_ORIF_EXPR, type, arg0, op2);
|
||||
return fold_build2 (TRUTH_ORIF_EXPR, type,
|
||||
fold_convert (type, arg0),
|
||||
op2);
|
||||
|
||||
return NULL_TREE;
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2006-04-16 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR target/26961
|
||||
* gcc.dg/fold-cond-1.c: New test case.
|
||||
* gcc.dg/pr26961-1.c: Likewise.
|
||||
|
||||
2006-04-16 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||
|
||||
PR libgfortran/27138
|
||||
|
28
gcc/testsuite/gcc.dg/fold-cond-1.c
Normal file
28
gcc/testsuite/gcc.dg/fold-cond-1.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-original" } */
|
||||
|
||||
_Bool test1(int a, int b)
|
||||
{
|
||||
return a ? b : 0;
|
||||
}
|
||||
|
||||
_Bool test2(int c, int d)
|
||||
{
|
||||
return c ? d : 1;
|
||||
}
|
||||
|
||||
_Bool test3(int e, int f)
|
||||
{
|
||||
return e ? 0 : f;
|
||||
}
|
||||
|
||||
_Bool test4(int g, int h)
|
||||
{
|
||||
return g ? 1 : h;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "a != 0 \&\& b != 0" 1 "original" } } */
|
||||
/* { dg-final { scan-tree-dump-times "c == 0 \\|\\| d != 0" 1 "original" } } */
|
||||
/* { dg-final { scan-tree-dump-times "e == 0 \&\& f != 0" 1 "original" } } */
|
||||
/* { dg-final { scan-tree-dump-times "\\(g \\| h\\) != 0" 1 "original" } } */
|
||||
/* { dg-final { cleanup-tree-dump "original" } } */
|
8
gcc/testsuite/gcc.dg/pr26961-1.c
Normal file
8
gcc/testsuite/gcc.dg/pr26961-1.c
Normal file
@ -0,0 +1,8 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
long long foo(int i, int j)
|
||||
{
|
||||
return i ? (long long)(!j) : 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user