aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-05-19 19:44:35 +0000
committerAndrew Pinski <apinski@marvell.com>2023-05-20 05:04:50 +0000
commitc5df248509b489364c573e8b7f5f4c2fdb87f5b4 (patch)
treec1d1b22c5de1589e6478a6e169907c1ef732fbe3 /gcc/expr.cc
parent5c68c27f3d093da89cdeee2706a03b8e759f111b (diff)
downloadgcc-c5df248509b489364c573e8b7f5f4c2fdb87f5b4.zip
gcc-c5df248509b489364c573e8b7f5f4c2fdb87f5b4.tar.gz
gcc-c5df248509b489364c573e8b7f5f4c2fdb87f5b4.tar.bz2
Use BIT_FIELD_REF inside fold_single_bit_test
Instead of depending on combine to do the extraction, Let's create a tree which will expand directly into the extraction. This improves code generation on some targets. gcc/ChangeLog: * expr.cc (fold_single_bit_test): Use BIT_FIELD_REF instead of shift/and.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r--gcc/expr.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index b5bc3fa..d04e8ed 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12957,22 +12957,21 @@ fold_single_bit_test (location_t loc, enum tree_code code,
intermediate_type = ops_unsigned ? unsigned_type : signed_type;
inner = fold_convert_loc (loc, intermediate_type, inner);
- if (bitnum != 0)
- inner = build2 (RSHIFT_EXPR, intermediate_type,
- inner, size_int (bitnum));
+ tree bftype = build_nonstandard_integer_type (1, 1);
+ int bitpos = bitnum;
- one = build_int_cst (intermediate_type, 1);
+ if (BYTES_BIG_ENDIAN)
+ bitpos = GET_MODE_BITSIZE (operand_mode) - 1 - bitpos;
- if (code == EQ_EXPR)
- inner = fold_build2_loc (loc, BIT_XOR_EXPR, intermediate_type, inner, one);
+ inner = build3_loc (loc, BIT_FIELD_REF, bftype, inner,
+ bitsize_int (1), bitsize_int (bitpos));
- /* Put the AND last so it can combine with more things. */
- inner = build2 (BIT_AND_EXPR, intermediate_type, inner, one);
+ one = build_int_cst (bftype, 1);
- /* Make sure to return the proper type. */
- inner = fold_convert_loc (loc, result_type, inner);
+ if (code == EQ_EXPR)
+ inner = fold_build2_loc (loc, BIT_XOR_EXPR, bftype, inner, one);
- return inner;
+ return fold_convert_loc (loc, result_type, inner);
}
/* Generate code to calculate OPS, and exploded expression