http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60501
Bug ID: 60501 Summary: LRA emits add patterns which might clobber cc Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: krebbel at gcc dot gnu.org Created attachment 32333 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32333&action=edit Experimental fix This actually is a follow-on to #57604. While debugging 435.gromacs I've noticed that LRA still emits add patterns which might clobber cc without actually checking whether this is valid. no lra: 4982a6: eb e6 00 01 00 df sllk %r14,%r6,1 4982ac: a7 78 00 02 lhi %r7,2 4982b0: 40 7e a0 00 sth %r7,0(%r14,%r10) 4982b4: 40 7e a0 02 sth %r7,2(%r14,%r10) 4982b8: 40 7e a0 04 sth %r7,4(%r14,%r10) 4982bc: b9 f2 30 06 locrnle %r0,%r6 lra: 49823e: eb 9e 00 01 00 df sllk %r9,%r14,1 <-- cc set 498244: 18 69 lr %r6,%r9 498246: 1a 6a ar %r6,%r10 <-- cc clobber 498248: e5 44 60 00 00 02 mvhhi 0(%r6),2 49824e: a7 78 00 02 lhi %r7,2 498252: a7 38 00 04 lhi %r3,4 498256: 1a 7a ar %r7,%r10 <-- cc clobber 498258: 1a 3a ar %r3,%r10 <-- cc clobber 49825a: 1a 79 ar %r7,%r9 <-- cc clobber 49825c: 1a 39 ar %r3,%r9 <-- cc clobber 49825e: e5 44 70 00 00 02 mvhhi 0(%r7),2 498264: b9 f2 30 0e locrnle %r0,%r14 <-- cc use Apart from the no lra code looking much better the LRA variant is dies with a miscompare. A potential solution has already been discussed in: http://gcc.gnu.org/ml/gcc-patches/2013-06/msg01174.html Richard proposed to have standard pattern names for pointer arithmetic. I've tried to implement this for S/390. With the attached (untested) patch I get the following: 97e: eb 9e 00 01 00 df sllk %r9,%r14,1 984: 41 69 a0 00 la %r6,0(%r9,%r10) 988: e5 44 60 00 00 02 mvhhi 0(%r6),2 98e: 19 0e cr %r0,%r14 990: a7 78 00 02 lhi %r7,2 994: 41 37 a0 00 la %r3,0(%r7,%r10) 998: 41 63 90 00 la %r6,0(%r3,%r9) 99c: e5 44 60 00 00 02 mvhhi 0(%r6),2 9a2: b9 f2 30 0e locrnle %r0,%r14