reginfo.c
39.8 KB
-
PR 69577: Invalid RA of destination subregs · 2692b5c8
In PR 69577 we have: A: (set (reg:V2TI X) ...) B: (set (subreg:TI (reg:V2TI X) 0) ...) X gets allocated to an AVX register, as usual for V2TI. The problem is that the movti for B doesn't then preserve the other half of X, even though the subreg semantics are supposed to guarantee that. If instead the same value had been set by: A': (set (subreg:TI (reg:V2TI X) 16) ...) B: (set (subreg:TI (reg:V2TI X) 0) ...) the subreg in A' would have prevented the use of AVX registers for X, since you can't directly access the high part. IMO these are really the same thing. An alternative way to view it is that the original sequence is equivalent to: A: (set (reg:V2TI X) ...) B1: (set (subreg:TI (reg:V2TI X) 0) ...) B2: (set (subreg:TI (reg:V2TI X) 16) (subreg:TI (reg:V2TI X) 16)) in which B2 is a no-op and therefore implicit. The handling ought to be the same regardless of whether there is an rtl insn that explicitly assigns to (subreg:TI (reg:V2TI X) 16). This patch implements that idea. Hopefully the comments explain what's going on. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabihf. gcc/ PR rtl-optimization/69577 * reginfo.c (record_subregs_of_mode): Add a partial_def parameter. (find_subregs_of_mode): Update accordingly. Iterate over partial definitions. gcc/testsuite/ PR rtl-optimization/69577 * gcc.target/i386/pr69577.c: New test. From-SVN: r233143
Richard Sandiford committed