https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117860
Uroš Bizjak <ubizjak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ubizjak at gmail dot com
Status|NEW |ASSIGNED
--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 59773
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59773&action=edit
Proposed patch
Proposed patch does several things to enable combine to handle
addcarry/subborrow patterns:
- Fix wrong canonical form of addcarry<mode> insn and friends. In commutative
operand (PLUS RTX) binary operand (LTU) takes precedence before unary operand
(ZERO_EXTEND).
- Swap operands of GTU comparison to canonicalize addcarry/subborrow
comparison. Again, the canonical form of compare is PLUS RTX before ZERO_EXTEND
RTX. GTU comparison is not a carry flag comparison, so we have to swap operands
in x86_canonicalize_comparison to a non-canonical form to use LTU comparison.
- Return correct compare mode (CCCmode) for addcarry/subborrow pattern from
ix86_cc_mode, so combine is able to use correct compare mode for combined insn.
- Add *subborrow<mode>_1 pattern having const_scalar_int_operand predicate.
Here, canonicalization of SUB (op1, const) RTX to PLUS (op1, -const) causes
some additional processing when ckecking operands.
With the above changes, combine is able to create *addcarry_1/*subborrow_1
pattern with immediate operand:
SomeAddFunc:
addq %rcx, %rsi # 10 [c=4 l=3] adddi3_cc_overflow_1/0
movq %rdi, %rax # 33 [c=4 l=3] *movdi_internal/3
adcq $5, %rdx # 19 [c=4 l=4] *addcarrydi_1/0
movq %rsi, (%rdi) # 23 [c=4 l=3] *movdi_internal/5
movq %rdx, 8(%rdi) # 24 [c=4 l=4] *movdi_internal/5
setc %dl # 39 [c=4 l=3] *setcc_qi
movzbl %dl, %edx # 40 [c=4 l=3] zero_extendqidi2/0
movq %rdx, 16(%rdi) # 26 [c=4 l=4] *movdi_internal/5
ret # 43 [c=0 l=1] simple_return_internal
SomeSubFunc:
subq %rcx, %rsi # 10 [c=4 l=3] *subdi_3/0
movq %rdi, %rax # 42 [c=4 l=3] *movdi_internal/3
sbbq $17, %rdx # 19 [c=4 l=4] *subborrowdi_1/0
movq %rsi, (%rdi) # 33 [c=4 l=3] *movdi_internal/5
sbbq %rcx, %rcx # 29 [c=8 l=3] *x86_movdicc_0_m1_neg
movq %rdx, 8(%rdi) # 34 [c=4 l=4] *movdi_internal/5
movq %rcx, 16(%rdi) # 35 [c=4 l=4] *movdi_internal/5
ret # 51 [c=0 l=1] simple_return_internal