https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124649

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Expand does
(insn 35 34 36 4 (set (reg:SI 142 [ _6 ])
        (ashiftrt:SI (reg:SI 115 [ pretmp_40 ])
            (const_int 3 [0x3]))) "/app/example.cpp":13:7 -1
     (nil))
(insn 36 35 37 4 (set (reg:SI 103 [ _5 ])
        (and:SI (reg:SI 142 [ _6 ])
            (const_int 1 [0x1]))) "/app/example.cpp":14:5 -1
     (nil))
..
(insn 40 39 41 4 (set (mem:SI (reg/f:DI 108 [ c.4D.4638 ]) [1 (*c.4_21)[0]+0 S4
A32])
        (reg:SI 103 [ _5 ])) "/app/example.cpp":15:8 -1
     (nil))
(insn 41 40 42 4 (set (reg:SI 146)
        (mem:SI (reg/f:DI 108 [ c.4D.4638 ]) [1  S4 A32]))
"/app/example.cpp":17:12 discrim 33792 -1
     (nil))
(insn 42 41 43 4 (set (reg:VNx4SI 145)
        (subreg:VNx4SI (reg:SI 146) 0)) "/app/example.cpp":17:12 discrim 33792
-1
     (nil))


After combine we have:
```
(insn 36 35 39 3 (set (subreg:DI (reg:SI 103 [ _5 ]) 0)
        (zero_extract:DI (subreg:DI (reg:SI 115 [ pretmp_40 ]) 0)
            (const_int 1 [0x1])
            (const_int 3 [0x3]))) "/app/example.cpp":14:5 864 {*extzvdi}
     (expr_list:REG_DEAD (reg:SI 115 [ pretmp_40 ])
        (nil)))
(insn 43 42 45 3 (set (reg:VNx4QI 147 [ vect__10.18_30 ])
        (truncate:VNx4QI (subreg:VNx4SI (reg:SI 103 [ _5 ]) 0)))
"/app/example.cpp":17:12 discrim 33792 7223 {truncvnx4sivnx4qi2}
     (expr_list:REG_DEAD (reg:SI 103 [ _5 ])
        (nil)))
```

reload (LRA) does:
```
(insn 36 42 91 3 (set (reg:DI 2 x2 [161])
        (zero_extract:DI (reg:DI 2 x2 [orig:115 pretmp_40 ] [115])
            (const_int 1 [0x1])
            (const_int 3 [0x3]))) "/app/example.cpp":14:5 864 {*extzvdi}
     (nil))
(insn 91 36 43 3 (set (reg:DI 63 v31 [orig:103 _5 ] [103])
        (reg:DI 2 x2 [161])) "/app/example.cpp":14:5 105 {*movdi_aarch64}
     (nil))
(insn 43 91 39 3 (set (reg:VNx4QI 62 v30 [orig:147 vect__10.18_30 ] [147])
        (truncate:VNx4QI (reg:VNx4SI 63 v31 [orig:103 _5 ] [103])))
"/app/example.cpp":17:12 discrim 33792 7223 {truncvnx4sivnx4qi2}
     (nil))
```

Which is fine.

So the issue is the calls of partial_subreg_p in maybe_mode_change .

Maybe the fix is to add to maybe_mode_change :
  poly_int64 copy_prec = GET_MODE_PRECISION (copy_mode);
  poly_int64 new_prec = GET_MODE_PRECISION (new_mode);
  if (!ordered_p (copy_prec , new_prec))
    return NULL_RTX;

Since that skips the copy anyways.

Reply via email to