public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix expand_single_bit_test for big-endian
@ 2023-05-21  4:04 Andrew Pinski
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2023-05-21  4:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

I had thought extract_bit_field bitpos argument was the shifted position
and not the bitposition like BIT_FIELD_REF so I had removed the code which
would use the correct bitposition for BYTES_BIG_ENDIAN.

Committed as obvious; I checked big-endian MIPS to make sure we are now
producing the correct code.

gcc/ChangeLog:

	* expr.cc (expand_single_bit_test): Correct bitpos for big-endian.
---
 gcc/expr.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 02f24c00148..050efcd0b00 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12958,7 +12958,14 @@ expand_single_bit_test (location_t loc, enum tree_code code,
 
   rtx inner0 = expand_expr (inner, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
-  inner0 = extract_bit_field (inner0, 1, bitnum, 1, target,
+  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;
+
+  inner0 = extract_bit_field (inner0, 1, bitpos, 1, target,
 			      operand_mode, mode, 0, NULL);
 
   if (code == EQ_EXPR)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Fix expand_single_bit_test for big-endian
@ 2023-05-21  4:50 Andrew Pinski
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2023-05-21  4:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

I had thought extract_bit_field bitpos argument was the shifted position
and not the bitposition like BIT_FIELD_REF so I had removed the code which
would use the correct bitposition for BYTES_BIG_ENDIAN.

Committed as obvious; I checked big-endian MIPS to make sure we are now
producing the correct code.

gcc/ChangeLog:

	* expr.cc (expand_single_bit_test): Correct bitpos for big-endian.
---
 gcc/expr.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 02f24c00148..050efcd0b00 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12958,7 +12958,14 @@ expand_single_bit_test (location_t loc, enum tree_code code,
 
   rtx inner0 = expand_expr (inner, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
-  inner0 = extract_bit_field (inner0, 1, bitnum, 1, target,
+  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;
+
+  inner0 = extract_bit_field (inner0, 1, bitpos, 1, target,
 			      operand_mode, mode, 0, NULL);
 
   if (code == EQ_EXPR)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-21  4:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-21  4:04 [PATCH] Fix expand_single_bit_test for big-endian Andrew Pinski
2023-05-21  4:50 Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).