[RFC? PATCH]: Fix PR rtl-optimization/26449, ICE in loop invariant motion

Uros Bizjak ubizjak@gmail.com
Sat Sep 15 15:25:00 GMT 2007


This RFC fix the ICE in loop invariant motion (PR 
rtl-optimization/26449) is based on the fact that all reported recent 
failures were on RTX that set subreg of a pseudo, like:

(insn 147 146 148 21 loop-15.c:11 (set (subreg:V4SI (reg:V2DI 131) 0)
         (vec_select:V4SI (vec_concat:V8SI (reg:V4SI 139)
                 (reg:V4SI 134))
             (parallel [
                     (const_int 0 [0x0])
                     (const_int 4 [0x4])
                     (const_int 1 [0x1])
                     (const_int 5 [0x5])
                 ]))) 1270 {sse2_punpckldq} (nil))

By changing the code around line 1215 to

--cut here--
      /* If the SET_DEST of the invariant insn is a pseudo, we can just move
     the insn out of the loop.  Otherwise, we have to use gen_move_insn
     to let emit_move_insn produce a valid instruction stream.  */
      if ((REG_P (dest) && !HARD_REGISTER_P (dest))
      || (GET_CODE (dest) == SUBREG && REG_P (SUBREG_REG (dest))
          && !HARD_REGISTER_P (SUBREG_REG (dest))))
--cut here--

we pass SUBREG of the pseudo through the same path, decomposing above 
insn into (invariant):

(insn 147 146 151 2 loop-15.c:12 (set (reg:V4SI 153)
        (vec_select:V4SI (vec_concat:V8SI (reg:V4SI 139)
                (reg:V4SI 152))
            (parallel [
                    (const_int 0 [0x0])
                    (const_int 4 [0x4])
                    (const_int 1 [0x1])
                    (const_int 5 [0x5])
                ]))) 1270 {sse2_punpckldq} (nil))


(insn 198 212 148 22 loop-15.c:12 (set (subreg:V4SI (reg:V2DI 131) 0)
        (reg:V4SI 153)) -1 (nil))

gcc has no further problems to create expected asm:

        movdqa  .LC0(%rip), %xmm1
        leaq    64(%rsp), %r12
        pcmpgtd %xmm1, %xmm0
        movdqa  %xmm1, %xmm2
        movq    %r12, %r15
        punpckldq       %xmm0, %xmm2
        punpckhdq       %xmm0, %xmm1
        movdqa  %xmm2, 32(%rsp)
        movdqa  %xmm1, 16(%rsp)
2007-09-15  Uros Bizjak  <ubizjak@gmail.com>

        PR rtl-optimization/26449
        * loop-invariant.c (move_invariant_reg): Move insn out of the loop
        when SET_DEST of the invariant insn is a subreg of a pseudo.

The patch was bootstrapped and regression tested on x86_64-pc-linux-gnu. 
It fixes gcc.c-torture/execute/loop-15.c failure on x86_64.

OK for mainline?

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr26449-2.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070915/2441499d/attachment.txt>

More information about the Gcc-patches mailing list