[arm] Fix incorrect modes with 'borrow' operations
authorRichard Earnshaw <rearnsha@arm.com>
Thu, 18 Jul 2019 13:56:52 +0000 (13:56 +0000)
committerRichard Earnshaw <rearnsha@gcc.gnu.org>
Thu, 18 Jul 2019 13:56:52 +0000 (13:56 +0000)
commit24990170d318194b265c2fc76d93965275da462c
tree966a7a20f63f71c465144937ba4c8ab02e72595e
parentb01659aa867a8fee932ef389f5066495f531da77
[arm] Fix incorrect modes with 'borrow' operations

Looking through the arm backend I noticed that the modes used to pass
comparison types into subtract-with-carry operations were being
incorrectly set.  The result is that the compiler is not truly
self-consistent.  To clean this up I've introduced a new predicate,
arm_borrow_operation (borrowed from the AArch64 backend) which can
match the comparison type with the required mode and then fixed all
the patterns to use this.  The split patterns that were generating
incorrect modes have all obviously been fixed as well.

The basic rule for the use of a borrow is:
- if the condition code was set by a 'subtract-like' operation (subs, cmp),
  then use CCmode and LTU.
- if the condition code was by unsigned overflow of addition (adds), then
  use CC_Cmode and GEU.

* config/arm/predicates.md (arm_borrow_operation): New predicate.
* config/arm/arm.c (subdi3_compare1): Use CCmode for the split.
(arm_subdi3, subdi_di_zesidi, subdi_di_sesidi): Likewise.
(subdi_zesidi_zesidi): Likewise.
(negdi2_compare, negdi2_insn): Likewise.
(negdi_extensidi): Likewise.
(negdi_zero_extendsidi): Likewise.
(arm_cmpdi_insn): Likewise.
(subsi3_carryin): Use arm_borrow_operation.
(subsi3_carryin_const): Likewise.
(subsi3_carryin_const0): Likewise.
(subsi3_carryin_compare): Likewise.
(subsi3_carryin_compare_const): Likewise.
(subsi3_carryin_compare_const0): Likewise.
(subsi3_carryin_shift): Likewise.
(rsbsi3_carryin_shift): Likewise.
(negsi2_carryin_compare): Likewise.

From-SVN: r273572
gcc/ChangeLog
gcc/config/arm/arm.md
gcc/config/arm/predicates.md