diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-01 10:13:36 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-01 10:13:36 +0000 |
commit | b8ddd49bf81d3d47b6f7b27907729ac8b44a1aa7 (patch) | |
tree | d4483d63d139eff9738f540f3168a9f08952531c /gcc/fold-const.c | |
parent | 882b157fc018d6f285e54062ae38b387a4e13aa1 (diff) | |
download | gcc-b8ddd49bf81d3d47b6f7b27907729ac8b44a1aa7.tar.gz |
* fold-const.c (fold_ternary): Optimize BIT_FIELD_REF of VECTOR_CST.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100442 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 18e92e27c6a..13984d1c8be 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10284,6 +10284,29 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) } return NULL_TREE; + case BIT_FIELD_REF: + if (TREE_CODE (arg0) == VECTOR_CST + && type == TREE_TYPE (TREE_TYPE (arg0)) + && host_integerp (arg1, 1) + && host_integerp (op2, 1)) + { + unsigned HOST_WIDE_INT width = tree_low_cst (arg1, 1); + unsigned HOST_WIDE_INT idx = tree_low_cst (op2, 1); + + if (width != 0 + && simple_cst_equal (arg1, TYPE_SIZE (type)) == 1 + && (idx % width) == 0 + && (idx = idx / width) + < TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0))) + { + tree elements = TREE_VECTOR_CST_ELTS (arg0); + while (idx-- > 0) + elements = TREE_CHAIN (elements); + return TREE_VALUE (elements); + } + } + return NULL_TREE; + default: return NULL_TREE; } /* switch (code) */ |