OSDN Git Service

gcc/
authoramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Apr 2006 03:41:34 +0000 (03:41 +0000)
committeramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Apr 2006 03:41:34 +0000 (03:41 +0000)
PR middle-end/27260
* builtins.c (expand_builtin_memset): Expand val in original mode.
gcc/testsuite/
PR middle-end/27260
* gcc.c-torture/execute/pr27260.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113341 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr27260.c [new file with mode: 0644]

index 66e8188..9bf6279 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-28  Alan Modra  <amodra@bigpond.net.au>
+
+       PR middle-end/27260
+       * builtins.c (expand_builtin_memset): Expand val in original mode.
+
 2006-04-27  Eric Christopher  <echristo@apple.com>
 
        * target-def.h (TARGET_SET_DEFAULT_TYPE_ATTRIBUTES): Bracket
index 5747de4..085c1fa 100644 (file)
@@ -3421,11 +3421,11 @@ expand_builtin_memset (tree arglist, rtx target, enum machine_mode mode,
 
       if (TREE_CODE (val) != INTEGER_CST)
        {
-         tree cval;
          rtx val_rtx;
 
-         cval = fold_build1 (CONVERT_EXPR, unsigned_char_type_node, val);
-         val_rtx = expand_normal (cval);
+         val_rtx = expand_normal (val);
+         val_rtx = convert_to_mode (TYPE_MODE (unsigned_char_type_node),
+                                    val_rtx, 0);
 
          /* Assume that we can memset by pieces if we can store the
           * the coefficients by pieces (in the required modes).
index b4ebae7..de29bc8 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/27260
+       * gcc.c-torture/execute/pr27260.c: New.
+
 2006-04-28  Alan Modra  <amodra@bigpond.net.au>
 
        PR middle-end/27095
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr27260.c b/gcc/testsuite/gcc.c-torture/execute/pr27260.c
new file mode 100644 (file)
index 0000000..daec0c3
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR middle-end/27260 */
+
+extern void abort (void);
+extern void *memset (void *, int, __SIZE_TYPE__);
+
+char buf[65];
+
+void
+foo (int x)
+{
+  memset (buf, x != 2 ? 1 : 0, 64);
+}
+
+int
+main (void)
+{
+  int i;
+  buf[64] = 2;
+  for (i = 0; i < 64; i++)
+    if (buf[i] != 0)
+      abort ();
+  foo (0);
+  for (i = 0; i < 64; i++)
+    if (buf[i] != 1)
+      abort ();
+  foo (2);
+  for (i = 0; i < 64; i++)
+    if (buf[i] != 0)
+      abort ();
+  if (buf[64] != 2)
+    abort ();
+  return 0;
+}