[arm] Improve constant handling for usubvsi4.
commita79048f6250febc1acce09d790035276d534e754
authorRichard Earnshaw <rearnsha@arm.com>
Fri, 18 Oct 2019 19:04:46 +0000 (18 19:04 +0000)
committerRichard Earnshaw <rearnsha@gcc.gnu.org>
Fri, 18 Oct 2019 19:04:46 +0000 (18 19:04 +0000)
treef1e52a3111c47fb41bbec05a282a1f88a986cbd6
parentfa62df0e600ef617bce549d64026c0e5cc817c31
[arm] Improve constant handling for usubvsi4.

This patch improves the expansion of usubvsi4 by allowing suitable
constants to be passed directly.  Unlike normal subtraction, either
operand may be a constant (and indeed I have seen cases where both can
be with LTO enabled).  One interesting testcase that improves as a
result of this is:

unsigned f6 (unsigned a)
{
  unsigned x;
  return __builtin_sub_overflow (5U, a, &x) ? 0 : x;
}

Which previously compiled to:

rsbs r3, r0, #5
cmp r0, #5
movls r0, r3
movhi r0, #0

but now generates the optimal sequence:

rsbs r0, r0, #5
movcc r0, #0

* config/arm/arm.md (usubv<mode>4): Delete expansion.
(usubvsi4): New pattern.  Allow some immediate values for inputs.
(usubvdi4): New pattern.

From-SVN: r277187
gcc/ChangeLog
gcc/config/arm/arm.md