public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH/expand] PR64011 Adjust bitsize when partial overflow happen for big-endian
@ 2014-12-30 10:41 Jiong Wang
  2015-01-09  5:46 ` Jeff Law
  0 siblings, 1 reply; 13+ messages in thread
From: Jiong Wang @ 2014-12-30 10:41 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

PR64011 is actually a general problem on all target support bit insertion
instructions.

we overflow check at the start of store_bit_field_1, but that only check the
situation where the field lies completely outside the register, while there do
have situation where the field lies partly in the register, we need to adjust
bitsize for this partial overflow situation. Without this fix, pr48335-2.c on
big-endian will broken on those arch support bit insert instruction, like arm, aarch64.

the testcase is just pr48335-2.c, before this patch is will ICE on arm and =
generate
invalid assembly on AArch64. after this patch, problem gone away.

ok for trunk?

bootstrap OK on x86-64 && aarch64.
no regression on x86-64

thanks.

gcc/
    PR64011
    * expmed.c (store_bit_field_using_insv): Adjust bitsize when there is partial overflow.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-expmed-partial-overflow.patch --]
[-- Type: text/x-patch; name=fix-expmed-partial-overflow.patch, Size: 1000 bytes --]

diff --git a/gcc/expmed.c b/gcc/expmed.c
index 0304e46..61aec39 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -535,6 +535,16 @@ store_bit_field_using_insv (const extraction_insn *insv, rtx op0,
       copy_back = true;
     }
 
+  /* There are similar overflow check at the start of store_bit_field_1,
+     but that only check the situation where the field lies completely
+     outside the register, while there do have situation where the field
+     lies partialy in the register, we need to adjust bitsize for this
+     partial overflow situation.  Without this fix, pr48335-2.c on big-endian
+     will broken on those arch support bit insert instruction, like arm, aarch64
+     etc.  */
+  if (bitsize + bitnum > unit && bitnum < unit)
+    bitsize = unit - bitnum;
+
   /* If BITS_BIG_ENDIAN is zero on a BYTES_BIG_ENDIAN machine, we count
      "backwards" from the size of the unit we are inserting into.
      Otherwise, we count bits from the most significant on a

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

end of thread, other threads:[~2015-01-16 10:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-30 10:41 [PATCH/expand] PR64011 Adjust bitsize when partial overflow happen for big-endian Jiong Wang
2015-01-09  5:46 ` Jeff Law
2015-01-09 13:40   ` Jiong Wang
2015-01-09 20:12     ` Jiong Wang
2015-01-13 22:17     ` Jeff Law
2015-01-13 22:47       ` Joseph Myers
2015-01-14  6:42         ` Jeff Law
2015-01-14 23:15       ` Jiong Wang
2015-01-15  4:38         ` Jeff Law
2015-01-15 16:36           ` Jiong Wang
2015-01-15 18:31             ` Jeff Law
2015-01-15 22:16             ` Joseph Myers
2015-01-16 10:45               ` [COMMITTED][PATCH/expand] " Jiong Wang

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).