This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [AArch64] Fix possible wrong code generation when comparing DImode values.


On 23/05/13 09:17, James Greenhalgh wrote:

Hi,

With the aarch64_cm<optab>di patterns a bug was introduced. While the
unsplit versions of these patterns, which operate in the
SIMD register set, do not clobber CC_REGNUM, the split versions, which
operate in the general purpose register set, do clobber CC_REGNUM.

This causes a problem if scheduling rearranges the unsplit version
of these instructions. For example, if we have:

   aarch64_cmeqdi_unsplit
   set_cc_flags
   jump

Then we could schedule as

   set_cc_flags
   aarch64_cmeqdi_unsplit
   jump

Because the unsplit version does not clobber CC_REGNUM.

If we now decide to split we get:

   set_cc_flags
   aarch64_cmeqdi_set_cc_flags
   aarch64_cmeqdi_use_cc_flags
   jump

And the jump uses the wrong value for cc_flags.

We fix this problem by adding the clobber of CC_REGNUM to
the aarch64_cm<optab>di patterns. This may restrict the
scheduling opportunities available, but should prevent
incorrect code generation.

Tested on aarch64-none-linux-gnu, aarch64-none-elf with no
regressions. The bug manifest itself in the libstdc++ testsuite,
so I've double checked there to ensure that the bug has cleared.

Thanks,
James

---
gcc/

2013-05-17  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/aarch64/aarch64-simd.md
	(aarch64_cm<optab>di): Add clobber of CC_REGNUM to unsplit pattern.



OK.

R.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]