Commit 8813f50d by Bin Cheng Committed by Bin Cheng

* tree-affine.c (tree_to_aff_combination): Handle (T1)(X + X).

From-SVN: r248956
parent 1b92ccde
2017-06-07 Bin Cheng <bin.cheng@arm.com> 2017-06-07 Bin Cheng <bin.cheng@arm.com>
* tree-affine.c (tree_to_aff_combination): Handle (T1)(X + X).
2017-06-07 Bin Cheng <bin.cheng@arm.com>
(aff_combination_expand): Move (T1)(X *+- CST) simplification to ... (aff_combination_expand): Move (T1)(X *+- CST) simplification to ...
(tree_to_aff_combination): ... here. (tree_to_aff_combination): ... here.
......
...@@ -375,19 +375,26 @@ tree_to_aff_combination (tree expr, tree type, aff_tree *comb) ...@@ -375,19 +375,26 @@ tree_to_aff_combination (tree expr, tree type, aff_tree *comb)
if ((icode == PLUS_EXPR || icode == MINUS_EXPR || icode == MULT_EXPR) if ((icode == PLUS_EXPR || icode == MINUS_EXPR || icode == MULT_EXPR)
&& TREE_CODE (itype) == INTEGER_TYPE && TREE_CODE (itype) == INTEGER_TYPE
&& TREE_CODE (otype) == INTEGER_TYPE && TREE_CODE (otype) == INTEGER_TYPE
&& TYPE_PRECISION (otype) > TYPE_PRECISION (itype) && TYPE_PRECISION (otype) > TYPE_PRECISION (itype))
&& TYPE_OVERFLOW_UNDEFINED (itype) {
&& TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST) tree op0 = TREE_OPERAND (inner, 0), op1 = TREE_OPERAND (inner, 1);
{
/* Convert (T1)(X *+- CST) into (T1)X *+- (T1)CST if X's type has /* If inner type has undefined overflow behavior, fold conversion
undefined overflow behavior. */ for below two cases:
tree op0 = fold_convert (otype, TREE_OPERAND (inner, 0)); (T1)(X *+- CST) -> (T1)X *+- (T1)CST
tree op1 = fold_convert (otype, TREE_OPERAND (inner, 1)); (T1)(X + X) -> (T1)X + (T1)X. */
if (TYPE_OVERFLOW_UNDEFINED (itype)
&& (TREE_CODE (op1) == INTEGER_CST
|| (icode == PLUS_EXPR && operand_equal_p (op0, op1, 0))))
{
op0 = fold_convert (otype, op0);
op1 = fold_convert (otype, op1);
expr = fold_build2 (icode, otype, op0, op1); expr = fold_build2 (icode, otype, op0, op1);
tree_to_aff_combination (expr, type, comb); tree_to_aff_combination (expr, type, comb);
return; return;
} }
} }
}
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment