]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR rtl-optimization/70174
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Mar 2016 12:07:01 +0000 (12:07 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Mar 2016 12:07:01 +0000 (12:07 +0000)
* expmed.c (store_bit_field_using_insv): Use gen_lowpart_if_possible
followed by gen_lowpart on force_reg instead of just gen_lowpart.

* gcc.dg/pr70174.c: New test.

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

gcc/ChangeLog
gcc/expmed.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr70174.c [new file with mode: 0644]

index 171a52d1ec8cc71101581e3a02150fab456034dc..09ea7f7bd7a277d890702c4aa4ad8459f1767f4f 100644 (file)
@@ -1,5 +1,9 @@
 2016-03-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/70174
+       * expmed.c (store_bit_field_using_insv): Use gen_lowpart_if_possible
+       followed by gen_lowpart on force_reg instead of just gen_lowpart.
+
        PR tree-optimization/70169
        * tree-ssa-loop.c (gen_lsm_tmp_name): Handle FUNCTION_DECL and
        LABEL_DECL like VAR_DECL.  Emit nothing instead of gcc_unreachable
index 829b967b3ca2104e996cac3a7536d6953652a02e..31d905bd3d5739f360ba7621c74c07037b846832 100644 (file)
@@ -658,24 +658,28 @@ store_bit_field_using_insv (const extraction_insn *insv, rtx op0,
     {
       if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize)
        {
+         rtx tmp;
          /* Optimization: Don't bother really extending VALUE
             if it has all the bits we will actually use.  However,
             if we must narrow it, be sure we do it correctly.  */
 
          if (GET_MODE_SIZE (GET_MODE (value)) < GET_MODE_SIZE (op_mode))
            {
-             rtx tmp;
-
              tmp = simplify_subreg (op_mode, value1, GET_MODE (value), 0);
              if (! tmp)
                tmp = simplify_gen_subreg (op_mode,
                                           force_reg (GET_MODE (value),
                                                      value1),
                                           GET_MODE (value), 0);
-             value1 = tmp;
            }
          else
-           value1 = gen_lowpart (op_mode, value1);
+           {
+             tmp = gen_lowpart_if_possible (op_mode, value1);
+             if (! tmp)
+               tmp = gen_lowpart (op_mode, force_reg (GET_MODE (value),
+                                                      value1));
+           }
+         value1 = tmp;
        }
       else if (CONST_INT_P (value))
        value1 = gen_int_mode (INTVAL (value), op_mode);
index 75fe4ac519b877caa65a0fde1c4aa23dc6490684..a1035ef7a46dcc4ea67c97299f5453c8017229f2 100644 (file)
@@ -1,5 +1,8 @@
 2016-03-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/70174
+       * gcc.dg/pr70174.c: New test.
+
        PR tree-optimization/70169
        * gcc.dg/pr70169.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr70174.c b/gcc/testsuite/gcc.dg/pr70174.c
new file mode 100644 (file)
index 0000000..8a3bc90
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR rtl-optimization/70174 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct S { int f : 4; } a;
+  
+void
+foo (void)
+{ 
+  a.f = foo;   /* { dg-warning "assignment makes integer from pointer without a cast" } */
+}