Hello!

According to [1], invalid canonization from ASHIFT to MULT was removed
a while ago. Some instruction patterns (like the one below) needs to
be updated from MULT to ASHIFT, and alpha was left behind.
(define_insn "*sadd<modesuffix>"
  [(set (match_operand:I48MODE 0 "register_operand" "=r,r")
    (plus:I48MODE
     (mult:I48MODE (match_operand:I48MODE 1 "reg_not_elim_operand" "r,r")
               (match_operand:I48MODE 2 "const48_operand" "I,I"))
     (match_operand:I48MODE 3 "sext_add_operand" "rI,O")))]

The attached patch rewrites the affected patterns on alpha.

However, patch [1] introduced a combiner regression, where:

int s4l (int a, int b)
{
  return a + b * 4;
}

doesn't get simplified to a single instruction anymore. The combiner tries with:

(set (reg:DI 76)
    (sign_extend:DI (plus:SI (subreg:SI (ashift:DI (reg:DI 17 $17 [ b ])
                    (const_int 2 [0x2])) 0)
            (reg:SI 16 $16 [ a ]))))

which doesn't match due to the SImode subreg of the inner RTX.

This can be solved by adding subreg to the insn pattern in alpha.md,
but it looks like a regression in the generic part of the compiler,
since gcc-5 was able to simplify this combination.

[1] https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01841.html

2018-01-04  Uros Bizjak  <ubiz...@gmail.com>

    PR target/83628
    * config/alpha/alpha.md (*sadd<modesuffix>): Use ASHIFT
    instead of MULT rtx.  Update all corresponding splitters.
    (*saddl_se): Ditto.
    (*ssub<modesuffix>): Ditto.
    (*ssubl_se): Ditto.
    (*cmp_sadd_di): Update split patterns.
    (*cmp_sadd_si): Ditto.
    (*cmp_sadd_sidi): Ditto.
    (*cmp_ssub_di): Ditto.
    (*cmp_ssub_si): Ditto.
    (*cmp_ssub_sidi): Ditto.
    * config/alpha/predicates.md (const23_operand): New predicate.
    * config/alpha/alpha.c (alpha_rtx_costs) [PLUS, MINUS]:
    Look for ASHIFT, not MULT inner operand.
    (alpha_split_conditional_move): Update for *sadd<modesuffix> change.

testsuite/ChangeLog:

2018-01-04  Uros Bizjak  <ubiz...@gmail.com>

    PR target/83628
    * gcc.target/alpha/pr83628-1.c: New test.
    * gcc.target/alpha/pr83628-2.c: Ditto.

Patch was bootstrapped and regression tested on alpha[,ev68]-linux-gnu.

Committed to mainline.

Uros.

Reply via email to