On 6/4/23 23:53, Andrew Pinski via Gcc-patches wrote:
After expanding directly to rtl instead of
creating a tree, we could end up with
a const_int which is not ready to be handled
by extract_bit_field.
So need to the constant folding here instead.
OK? bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR middle-end/110117
gcc/ChangeLog:
* expr.cc (expand_single_bit_test): Handle
const_int from expand_expr.
gcc/testsuite/ChangeLog:
* gcc.dg/pr110117-1.c: New test.
* gcc.dg/pr110117-2.c: New test.
---
gcc/expr.cc | 10 +++++++---
gcc/testsuite/gcc.dg/pr110117-1.c | 31 +++++++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/pr110117-2.c | 7 +++++++
3 files changed, 45 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/pr110117-1.c
create mode 100644 gcc/testsuite/gcc.dg/pr110117-2.c
diff --git a/gcc/expr.cc b/gcc/expr.cc
index ca008cd453e..868d812eb1a 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12958,12 +12958,16 @@ expand_single_bit_test (location_t loc, enum
tree_code code,
rtx inner0 = expand_expr (inner, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+ if (CONST_SCALAR_INT_P (inner0))
+ {
+ wide_int t = rtx_mode_t (inner0, operand_mode);
+ bool setp = (wi::lrshift(t, bitnum) & 1) != 0;
Formatting nit. Space before the open paren for wi::lrshift's args.
OK with that change.
jeff