fold-const.c (220150) | fold-const.c (235623) |
---|---|
1/* Fold a constant sub-tree into a single node for C-compiler 2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 4 Free Software Foundation, Inc. 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify it under --- 6643 unchanged lines hidden (view full) --- 6652 && TREE_CODE (shorter_type) == POINTER_TYPE 6653 && TREE_CODE (TREE_TYPE (shorter_type)) == FUNCTION_TYPE) 6654 return NULL_TREE; 6655#endif 6656 6657 if (TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (shorter_type)) 6658 return NULL_TREE; 6659 | 1/* Fold a constant sub-tree into a single node for C-compiler 2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 4 Free Software Foundation, Inc. 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify it under --- 6643 unchanged lines hidden (view full) --- 6652 && TREE_CODE (shorter_type) == POINTER_TYPE 6653 && TREE_CODE (TREE_TYPE (shorter_type)) == FUNCTION_TYPE) 6654 return NULL_TREE; 6655#endif 6656 6657 if (TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (shorter_type)) 6658 return NULL_TREE; 6659 |
6660 arg1_unw = get_unwidened (arg1, shorter_type); | 6660 arg1_unw = get_unwidened (arg1, NULL_TREE); |
6661 6662 /* If possible, express the comparison in the shorter mode. */ 6663 if ((code == EQ_EXPR || code == NE_EXPR 6664 || TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type)) 6665 && (TREE_TYPE (arg1_unw) == shorter_type | 6661 6662 /* If possible, express the comparison in the shorter mode. */ 6663 if ((code == EQ_EXPR || code == NE_EXPR 6664 || TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type)) 6665 && (TREE_TYPE (arg1_unw) == shorter_type |
6666 || (TYPE_PRECISION (shorter_type) 6667 >= TYPE_PRECISION (TREE_TYPE (arg1_unw))) |
|
6666 || (TREE_CODE (arg1_unw) == INTEGER_CST 6667 && (TREE_CODE (shorter_type) == INTEGER_TYPE 6668 || TREE_CODE (shorter_type) == BOOLEAN_TYPE) 6669 && int_fits_type_p (arg1_unw, shorter_type)))) 6670 return fold_build2 (code, type, arg0_unw, 6671 fold_convert (shorter_type, arg1_unw)); 6672 6673 if (TREE_CODE (arg1_unw) != INTEGER_CST --- 3968 unchanged lines hidden (view full) --- 10642 constant cannot be the first operand. */ 10643 if (TREE_CODE (arg0) == BIT_AND_EXPR 10644 && integer_zerop (arg1)) 10645 { 10646 tree arg00 = TREE_OPERAND (arg0, 0); 10647 tree arg01 = TREE_OPERAND (arg0, 1); 10648 if (TREE_CODE (arg00) == LSHIFT_EXPR 10649 && integer_onep (TREE_OPERAND (arg00, 0))) | 6668 || (TREE_CODE (arg1_unw) == INTEGER_CST 6669 && (TREE_CODE (shorter_type) == INTEGER_TYPE 6670 || TREE_CODE (shorter_type) == BOOLEAN_TYPE) 6671 && int_fits_type_p (arg1_unw, shorter_type)))) 6672 return fold_build2 (code, type, arg0_unw, 6673 fold_convert (shorter_type, arg1_unw)); 6674 6675 if (TREE_CODE (arg1_unw) != INTEGER_CST --- 3968 unchanged lines hidden (view full) --- 10644 constant cannot be the first operand. */ 10645 if (TREE_CODE (arg0) == BIT_AND_EXPR 10646 && integer_zerop (arg1)) 10647 { 10648 tree arg00 = TREE_OPERAND (arg0, 0); 10649 tree arg01 = TREE_OPERAND (arg0, 1); 10650 if (TREE_CODE (arg00) == LSHIFT_EXPR 10651 && integer_onep (TREE_OPERAND (arg00, 0))) |
10650 return 10651 fold_build2 (code, type, 10652 build2 (BIT_AND_EXPR, TREE_TYPE (arg0), 10653 build2 (RSHIFT_EXPR, TREE_TYPE (arg00), 10654 arg01, TREE_OPERAND (arg00, 1)), 10655 fold_convert (TREE_TYPE (arg0), 10656 integer_one_node)), 10657 arg1); 10658 else if (TREE_CODE (TREE_OPERAND (arg0, 1)) == LSHIFT_EXPR 10659 && integer_onep (TREE_OPERAND (TREE_OPERAND (arg0, 1), 0))) 10660 return 10661 fold_build2 (code, type, 10662 build2 (BIT_AND_EXPR, TREE_TYPE (arg0), 10663 build2 (RSHIFT_EXPR, TREE_TYPE (arg01), 10664 arg00, TREE_OPERAND (arg01, 1)), 10665 fold_convert (TREE_TYPE (arg0), 10666 integer_one_node)), 10667 arg1); | 10652 { 10653 tree tem = fold_build2 (RSHIFT_EXPR, TREE_TYPE (arg00), 10654 arg01, TREE_OPERAND (arg00, 1)); 10655 tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), tem, 10656 build_int_cst (TREE_TYPE (arg0), 1)); 10657 return fold_build2 (code, type, 10658 fold_convert (TREE_TYPE (arg1), tem), arg1); 10659 } 10660 else if (TREE_CODE (arg01) == LSHIFT_EXPR 10661 && integer_onep (TREE_OPERAND (arg01, 0))) 10662 { 10663 tree tem = fold_build2 (RSHIFT_EXPR, TREE_TYPE (arg01), 10664 arg00, TREE_OPERAND (arg01, 1)); 10665 tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), tem, 10666 build_int_cst (TREE_TYPE (arg0), 1)); 10667 return fold_build2 (code, type, 10668 fold_convert (TREE_TYPE (arg1), tem), arg1); 10669 } |
10668 } 10669 10670 /* If this is an NE or EQ comparison of zero against the result of a 10671 signed MOD operation whose second operand is a power of 2, make 10672 the MOD operation unsigned since it is simpler and equivalent. */ 10673 if (integer_zerop (arg1) 10674 && !TYPE_UNSIGNED (TREE_TYPE (arg0)) 10675 && (TREE_CODE (arg0) == TRUNC_MOD_EXPR --- 2950 unchanged lines hidden --- | 10670 } 10671 10672 /* If this is an NE or EQ comparison of zero against the result of a 10673 signed MOD operation whose second operand is a power of 2, make 10674 the MOD operation unsigned since it is simpler and equivalent. */ 10675 if (integer_zerop (arg1) 10676 && !TYPE_UNSIGNED (TREE_TYPE (arg0)) 10677 && (TREE_CODE (arg0) == TRUNC_MOD_EXPR --- 2950 unchanged lines hidden --- |