diff options
author | Richard Earnshaw <rearnsha@arm.com> | 2019-10-18 19:04:38 +0000 |
---|---|---|
committer | Richard Earnshaw <rearnsha@arm.com> | 2019-10-18 19:04:38 +0000 |
commit | 9ad644e1afdd5f7dda51a054c59ca47971ae4540 (patch) | |
tree | 56583c6d248e02eafd0d9dde04728a3aa05e74dd /gcc/testsuite | |
parent | e18c90dc696577fe86b9485bda44c32244e62da8 (diff) |
[arm] Early split addvdi4
This patch adds early splitting for addvdi4; it's very similar to the
uaddvdi4 splitter, but the details are just different enough in
places, especially for the patterns that match the splitting, where we
have to compare against the non-widened version to detect if overflow
occurred.
I've also added a testcase to the testsuite for a couple of constants
that caught me out during the development of this patch. They're
probably arm-specific values, but the test is generic enough that I've
included it for all targets.
[gcc]
* config/arm/arm.c (arm_select_cc_mode): Allow either the first
or second operand of the PLUS inside a DImode equality test to be
sign-extend when selecting CC_Vmode.
* config/arm/arm.md (addvdi4): Early-split the operation into SImode
instructions.
(addsi3_cin_vout_reg, addsi3_cin_vout_imm, addsi3_cin_vout_0): New
expand patterns.
(addsi3_cin_vout_reg_insn, addsi3_cin_vout_imm_insn): New patterns.
(addsi3_cin_vout_0): Likewise.
(adddi3_compareV): Delete.
[gcc/testsuite]
* gcc.dg/builtin-arith-overflow-3.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@277186 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/builtin-arith-overflow-3.c | 41 |
2 files changed, 45 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d5d934d1b86..4267ac48382 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2019-10-18 Richard Earnshaw <rearnsha@arm.com> + * gcc.dg/builtin-arith-overflow-3.c: New test. + +2019-10-18 Richard Earnshaw <rearnsha@arm.com> + * gcc.target/arm/negdi-3.c: Remove XFAIL markers. 2019-10-18 Richard Earnshaw <rearnsha@arm.com> diff --git a/gcc/testsuite/gcc.dg/builtin-arith-overflow-3.c b/gcc/testsuite/gcc.dg/builtin-arith-overflow-3.c new file mode 100644 index 00000000000..6feae1eb42f --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-arith-overflow-3.c @@ -0,0 +1,41 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +static int cnt = 0; + +#define LL_MIN ((long long)(-__LONG_LONG_MAX__ - 1)) + +#define SC1 (LL_MIN + 5) +#define UC1 ((1ULL << (__LONG_LONG_WIDTH__ - 1)) | 5ULL) +#define UC2 (~UC1) + +long long __attribute__ ((noinline, noclone)) +f1 (long long a) +{ + long long x; + if (__builtin_add_overflow (a, SC1, &x)) cnt++; + return x; +} + +unsigned long long __attribute__ ((noinline, noclone)) +f2 (unsigned long long a) +{ + unsigned long long x; + if (__builtin_add_overflow (a, UC1, &x)) + cnt++; + return x; +} + +int main () +{ + if (f1 (-5) != LL_MIN) __builtin_abort (); + if (cnt != 0) __builtin_abort (); + f1 (-6); + if (cnt != 1) __builtin_abort (); + cnt = 0; + if (f2 (UC2) != ~0ULL) __builtin_abort (); + if (cnt != 0) __builtin_abort (); + if (f2 (UC2 + 1) != 0) __builtin_abort (); + if (cnt != 1) __builtin_abort (); + return 0; +} |