* expmed.c (expand_shift): Don't use the target of the rotate as
target for the first expanded shift insn.
* testsuite/gcc.dg/
20050922-1.c: Testcase added.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104528
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-09-22 Andreas Krebbel <krebbel1@de.ibm.com>
+
+ * expmed.c (expand_shift): Don't use the target of the rotate as
+ target for the first expanded shift insn.
+ * testsuite/gcc.dg/20050922-1.c: Testcase added.
+
2005-09-21 Zdenek Dvorak <dvorakz@suse.cz>
PR tree-optimization/22438
shifted = force_reg (mode, shifted);
temp = expand_shift (left ? LSHIFT_EXPR : RSHIFT_EXPR,
- mode, shifted, new_amount, subtarget, 1);
+ mode, shifted, new_amount, 0, 1);
temp1 = expand_shift (left ? RSHIFT_EXPR : LSHIFT_EXPR,
- mode, shifted, other_amount, 0, 1);
+ mode, shifted, other_amount, subtarget, 1);
return expand_binop (mode, ior_optab, temp, temp1, target,
unsignedp, methods);
}
--- /dev/null
+/* This revealed a bug when rotates are expanded into
+ two shifts. */
+
+/* { dg-do run } */
+/* { dg-options "-O1 -std=c99" } */
+
+#include <stdint.h>
+
+extern void abort (void);
+
+uint32_t
+f (uint32_t *S, int j)
+{
+ uint32_t A, B, k, L[2] = {1234, 5678};
+ int i, m;
+
+ A = B = 0;
+ for (i = 0; i < j; i++)
+ {
+ k = (S[i] + A + B) & 0xffffffffL;
+ A = S[i] =
+ ((k << (3 & 0x1f)) | ((k & 0xffffffff) >> (32 - (3 & 0x1f))));
+
+ m = (int) (A + B);
+ k = (L[i] + A + B) & 0xffffffffL;
+ B = L[i] =
+ ((k << (m & 0x1f)) | ((k & 0xffffffff) >> (32 - (m & 0x1f))));
+ }
+ return L[0] + L[1];
+}
+
+int
+main ()
+{
+ uint32_t S[2] = {0xffff, 0xffffff};
+
+ if (f (S,2)!= 1392607300)
+ abort();
+
+ return 0;
+}