Commit 24990170 by Richard Earnshaw Committed by Richard Earnshaw

[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
parent b01659aa
2019-07-18 Richard Earnshaw <rearnsha@arm.com>
* 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.
2019-07-18 Bin Cheng <bin.linux@linux.alibaba.com> 2019-07-18 Bin Cheng <bin.linux@linux.alibaba.com>
PR tree-optimization/91137 PR tree-optimization/91137
......
...@@ -358,6 +358,27 @@ ...@@ -358,6 +358,27 @@
(define_special_predicate "lt_ge_comparison_operator" (define_special_predicate "lt_ge_comparison_operator"
(match_code "lt,ge")) (match_code "lt,ge"))
;; Match a "borrow" operation for use with SBC. The precise code will
;; depend on the form of the comparison. This is generally the inverse of
;; a carry operation, since the logic of SBC uses "not borrow" in it's
;; calculation.
(define_special_predicate "arm_borrow_operation"
(match_code "geu,ltu")
{
if (XEXP (op, 1) != const0_rtx)
return false;
rtx op0 = XEXP (op, 0);
if (!REG_P (op0) || REGNO (op0) != CC_REGNUM)
return false;
machine_mode ccmode = GET_MODE (op0);
if (ccmode == CC_Cmode)
return GET_CODE (op) == GEU;
else if (ccmode == CCmode)
return GET_CODE (op) == LTU;
return false;
}
)
;; The vsel instruction only accepts the ARM condition codes listed below. ;; The vsel instruction only accepts the ARM condition codes listed below.
(define_special_predicate "arm_vsel_comparison_operator" (define_special_predicate "arm_vsel_comparison_operator"
(and (match_operand 0 "expandable_comparison_operator") (and (match_operand 0 "expandable_comparison_operator")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment