From 75161d2ca5a9a3c94e5c2ce6365046693a964368 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Fri, 19 Aug 2011 15:01:41 +0000 Subject: [PATCH] tree-ssa-math-opts.c (convert_plusminus_to_widen): Convert add_rhs to the correct type. 2011-08-19 Andrew Stubbs gcc/ * tree-ssa-math-opts.c (convert_plusminus_to_widen): Convert add_rhs to the correct type. gcc/testsuite/ * gcc.target/arm/wmul-10.c: New file. From-SVN: r177909 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/arm/wmul-10.c | 12 ++++++++++++ gcc/tree-ssa-math-opts.c | 4 ++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arm/wmul-10.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 648c3b18032..ed79f12c910 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-08-19 Andrew Stubbs + + * tree-ssa-math-opts.c (convert_plusminus_to_widen): Convert add_rhs + to the correct type. + 2011-08-19 Andrew Stubbs * tree-ssa-math-opts.c (convert_mult_to_widen): Better handle diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f65d2ec57b..a711cc355a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-08-19 Andrew Stubbs + + * gcc.target/arm/wmul-10.c: New file. + 2011-08-19 Andrew Stubbs * gcc.target/arm/wmul-9.c: New file. diff --git a/gcc/testsuite/gcc.target/arm/wmul-10.c b/gcc/testsuite/gcc.target/arm/wmul-10.c new file mode 100644 index 00000000000..5ffd169ba95 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/wmul-10.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target arm_dsp } */ + + +unsigned long long +foo (unsigned short a, unsigned short *b, unsigned short *c) +{ + return (unsigned)a + (unsigned long long)*b * (unsigned long long)*c; +} + +/* { dg-final { scan-assembler "umlal" } } */ diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 5ba31b560b5..73206adceba 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2369,6 +2369,10 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple stmt, mult_rhs2 = build_and_insert_cast (gsi, loc, tmp, mult_rhs2); } + if (!useless_type_conversion_p (type, TREE_TYPE (add_rhs))) + add_rhs = build_and_insert_cast (gsi, loc, create_tmp_var (type, NULL), + add_rhs); + gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, mult_rhs1, mult_rhs2, add_rhs); update_stmt (gsi_stmt (*gsi)); -- 2.30.2