This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SH][committed] Add test case for PR 65153


Hi,

This adds the test case for PR 65153.
Tested with
make -k check-gcc RUNTESTFLAGS="compile.exp=pr65153.c
--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

Committed as r221257.

Cheers,
Oleg

gcc/testsuite/ChangeLog:
	PR target/65153
	* gcc.c-torture/compile/pr65153.c: New.
Index: gcc/testsuite/gcc.c-torture/compile/pr65153.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr65153.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr65153.c	(revision 0)
@@ -0,0 +1,40 @@
+/* { dg-additional-options "-fPIC" { target fpic } }  */
+
+typedef unsigned long word32;
+typedef unsigned char byte;
+typedef struct cast256_instance { word32 l_key[96];} cast256_key;
+word32 cast256_sbox[4][256] = {};
+void
+key (cast256_key *key, const word32 *in_key, const int key_len)
+{
+  word32 i, j, t, u, cm, cr, lk[8], tm[8], tr[8];
+  for (i = 0; i < 96; i += 8)
+    {
+      for (j = 0; j < 8; ++j)
+	{
+	  tm[j] = cm;
+	  cm += 0x6ed9eba1;
+	  tr[j] = cr;
+	  cr += 17;
+	}
+      t = (((tm[0] + lk[7]) << ((word32)(tr[0] & 31)))
+	   | ((tm[0] + lk[7]) >> (32 - (word32)(tr[0] & 31))));
+      u = cast256_sbox[0][((byte)((t) >> (8 * 3)))];
+      u ^= cast256_sbox[1][((byte)((t) >> (8 * 2)))];
+      lk[7] ^= u;
+      for (j = 0; j < 8; ++j)
+	{
+	  cm += 0x6ed9eba1;
+	  tr[j] = cr;
+	  cr += 17;
+	}
+      t = (((tm[0] + lk[7]) << ((word32)(tr[0] & 31)))
+	   | ((tm[0] + lk[7]) >> (32 - (word32)(tr[0] & 31))));
+      u = cast256_sbox[0][((byte)((t) >> (8 * 3)))];
+      u ^= cast256_sbox[1][((byte)((t) >> (8 * 2)))];
+      u -= cast256_sbox[2][((byte)((t) >> (8 * 1)))];
+      lk[2] ^= u;
+      lk[7] ^= u;
+      key->l_key[i + 1] = lk[2];
+    }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]