diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index da890f1..b6a9814 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -13281,10 +13281,10 @@ contains_label_p (tree st) tree fold_ternary_loc (location_t loc, enum tree_code code, tree type, - tree op0, tree op1, tree op2) + tree op0, tree op1, tree op2) { tree tem; - tree arg0 = NULL_TREE, arg1 = NULL_TREE; + tree arg0 = NULL_TREE, arg1 = NULL_TREE, arg2 = NULL_TREE; enum tree_code_class kind = TREE_CODE_CLASS (code); gcc_assert (IS_EXPR_CODE_CLASS (kind) @@ -13312,6 +13312,12 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, STRIP_NOPS (arg1); } + if (op2) + { + arg2 = op2; + STRIP_NOPS (arg2); + } + switch (code) { case COMPONENT_REF: @@ -13610,6 +13616,17 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, return NULL_TREE; + case FMA_EXPR: + /* For integers we can decompose the FMA if possible. */ + if (TREE_CODE (arg0) == INTEGER_CST + && TREE_CODE (arg1) == INTEGER_CST) + return fold_build2_loc (loc, PLUS_EXPR, type, + const_binop (MULT_EXPR, arg0, arg1), arg2); + if (integer_zerop (arg2)) + return fold_build2_loc (loc, MULT_EXPR, type, arg0, arg1); + + return fold_fma (loc, type, arg0, arg1, arg2); + default: return NULL_TREE; } /* switch (code) */ |