diff options
author | thopre01 <thopre01@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-28 10:20:19 +0000 |
---|---|---|
committer | thopre01 <thopre01@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-28 10:20:19 +0000 |
commit | 904c73a0fa6902e4c4bfe1422f67c5f9445c30f7 (patch) | |
tree | 79c23d259d3122536e27807b8eb8ee4dcdd18bb3 /gcc/tree-ssa-math-opts.c | |
parent | 260d579bfd5550f6f48e118ef745bcf19cd5bcb5 (diff) | |
download | gcc-904c73a0fa6902e4c4bfe1422f67c5f9445c30f7.tar.gz |
2015-01-28 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
PR tree-optimization/64718
* tree-ssa-math-opts.c (pass_optimize_bswap::execute): Make bswap_type
be a 16bit unsigned integer when n->range is 16.
(bswap_replace): Convert src to that type if necessary for all bswap
sizes. Fix rotation right notation in nearby comment. Use bswap_type
set in pass_optimize_bswap::execute ().
gcc/testsuite/
PR tree-optimization/64718
* gcc.c-torture/execute/pr64718.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220203 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r-- | gcc/tree-ssa-math-opts.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 479f49f3a90..e30116dab1a 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2355,30 +2355,28 @@ bswap_replace (gimple cur_stmt, gimple src_stmt, tree fndecl, tree bswap_type, tmp = src; + /* Convert the src expression if necessary. */ + if (!useless_type_conversion_p (TREE_TYPE (tmp), bswap_type)) + { + gimple convert_stmt; + + tmp = make_temp_ssa_name (bswap_type, NULL, "bswapsrc"); + convert_stmt = gimple_build_assign (tmp, NOP_EXPR, src); + gsi_insert_before (&gsi, convert_stmt, GSI_SAME_STMT); + } + /* Canonical form for 16 bit bswap is a rotate expression. Only 16bit values are considered as rotation of 2N bit values by N bits is generally not - equivalent to a bswap. Consider for instance 0x01020304 >> 16 which gives - 0x03040102 while a bswap for that value is 0x04030201. */ + equivalent to a bswap. Consider for instance 0x01020304 r>> 16 which + gives 0x03040102 while a bswap for that value is 0x04030201. */ if (bswap && n->range == 16) { tree count = build_int_cst (NULL, BITS_PER_UNIT); - bswap_type = TREE_TYPE (src); - src = fold_build2 (LROTATE_EXPR, bswap_type, src, count); + src = fold_build2 (LROTATE_EXPR, bswap_type, tmp, count); bswap_stmt = gimple_build_assign (NULL, src); } else - { - /* Convert the src expression if necessary. */ - if (!useless_type_conversion_p (TREE_TYPE (tmp), bswap_type)) - { - gimple convert_stmt; - tmp = make_temp_ssa_name (bswap_type, NULL, "bswapsrc"); - convert_stmt = gimple_build_assign (tmp, NOP_EXPR, src); - gsi_insert_before (&gsi, convert_stmt, GSI_SAME_STMT); - } - - bswap_stmt = gimple_build_call (fndecl, 1, tmp); - } + bswap_stmt = gimple_build_call (fndecl, 1, tmp); tmp = tgt; @@ -2386,6 +2384,7 @@ bswap_replace (gimple cur_stmt, gimple src_stmt, tree fndecl, tree bswap_type, if (!useless_type_conversion_p (TREE_TYPE (tgt), bswap_type)) { gimple convert_stmt; + tmp = make_temp_ssa_name (bswap_type, NULL, "bswapdst"); convert_stmt = gimple_build_assign (tgt, NOP_EXPR, tmp); gsi_insert_after (&gsi, convert_stmt, GSI_SAME_STMT); @@ -2498,7 +2497,7 @@ pass_optimize_bswap::execute (function *fun) /* Already in canonical form, nothing to do. */ if (code == LROTATE_EXPR || code == RROTATE_EXPR) continue; - load_type = uint16_type_node; + load_type = bswap_type = uint16_type_node; break; case 32: load_type = uint32_type_node; |