aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-06-04 19:42:08 -0700
committerAndrew Pinski <apinski@marvell.com>2023-06-06 20:02:49 -0700
commit3f085e45755643f13d4fa45a12a6ade45be98f95 (patch)
treec4130544f10cbca73d79e796b2aa0dc6ae5c9ed9 /gcc/expr.cc
parente60593f3881c72a96a3fa4844d73e8a2cd14f670 (diff)
downloadgcc-3f085e45755643f13d4fa45a12a6ade45be98f95.zip
gcc-3f085e45755643f13d4fa45a12a6ade45be98f95.tar.gz
gcc-3f085e45755643f13d4fa45a12a6ade45be98f95.tar.bz2
Handle const_int in expand_single_bit_test
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.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r--gcc/expr.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 1c5874b..868fa6e 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12952,12 +12952,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;
+ return (setp ^ (code == EQ_EXPR)) ? const1_rtx : const0_rtx;
+ }
int bitpos = bitnum;
- scalar_int_mode imode = as_a <scalar_int_mode>(GET_MODE (inner0));
-
if (BYTES_BIG_ENDIAN)
- bitpos = GET_MODE_BITSIZE (imode) - 1 - bitpos;
+ bitpos = GET_MODE_BITSIZE (operand_mode) - 1 - bitpos;
inner0 = extract_bit_field (inner0, 1, bitpos, 1, target,
operand_mode, mode, 0, NULL);