]> git.ipfire.org Git - thirdparty/gcc.git/commit
IRA: Ignore debug insns for uses in split_live_ranges_for_shrink_wrap. [PR116179]
authorAndrew Pinski <quic_apinski@quicinc.com>
Fri, 2 Aug 2024 17:04:40 +0000 (10:04 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 5 Aug 2024 02:44:29 +0000 (19:44 -0700)
commit01cca42f65f25d709264fe277d25d9db3d68c437
treeca71d0f82353ce0ba23e0dd232a91e83dbd680d0
parentc18c53db823b22204405e015cbb4d7b039f875c0
IRA: Ignore debug insns for uses in split_live_ranges_for_shrink_wrap. [PR116179]

Late_combine exposed this latent bug in split_live_ranges_for_shrink_wrap.
What it did was copy-prop regno 151 from regno 119 from:
```
(insn 2 264 3 2 (set (reg/f:DI 119 [ thisD.3697 ])
        (reg:DI 151)) "/app/example.cpp":19:13 70 {*movdi_aarch64}
     (expr_list:REG_DEAD (reg:DI 151)
        (nil)))
```

into these insns:
```
(debug_insn 147 146 148 5 (var_location:DI thisD.3727 (reg/f:DI 119 [ thisD.3697 ])) "/app/example.cpp":21:5 -1
     (nil))
....
(insn 167 166 168 7 (set (reg:DI 1 x1)
        (reg/f:DI 119 [ thisD.3697 ])) "/app/example.cpp":14:21 70 {*movdi_aarch64}
     (nil))
```

Both are valid things to do. The problem is split_live_ranges_for_shrink_wrap looks at the
uses of reg 151 and with and without debugging reg 151 have a different usage in different BBs.
The function is trying to find a splitting point for reg 151 and they are different. In the end
this causes register allocation difference.
The fix is for split_live_ranges_for_shrink_wrap to ignore uses that were in debug insns.

Bootstrappped and tested on x86_64-linux-gnu with no regressions.

PR rtl-optimization/116179

gcc/ChangeLog:

* ira.cc (split_live_ranges_for_shrink_wrap): For the uses loop,
only look at non-debug insns.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr116179-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/ira.cc
gcc/testsuite/g++.dg/torture/pr116179-1.C [new file with mode: 0644]