From 954873472d77d260530b9f2b6fe587594f2665c4 Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Fri, 10 Apr 2015 16:20:35 +0000 Subject: [PATCH] [ARM] PR 65694: Properly sign-extend large numbers before passing to GEN_INT in arm_canonicalize_comparison PR target/65694 * config/arm/arm.c (arm_canonicalize_comparison): Use ARM_SIGN_EXTEND when creating +1 values for SImode. PR target/65694 * g++.dg/torture/pr65694.C: New test. From-SVN: r221976 --- gcc/ChangeLog | 6 ++ gcc/config/arm/arm.c | 4 +- gcc/testsuite/ChangeLog | 5 + gcc/testsuite/g++.dg/torture/pr65694.C | 144 +++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr65694.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 05e48035f01..b001ee5c849 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-04-10 Kyrylo Tkachov + + PR target/65694 + * config/arm/arm.c (arm_canonicalize_comparison): Use ARM_SIGN_EXTEND + when creating +1 values for SImode. + 2015-04-10 Vladimir Makarov PR target/65729 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 8fd138856d5..04663999224 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -4814,7 +4814,7 @@ arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1, if (i != maxval && (const_ok_for_arm (i + 1) || const_ok_for_arm (-(i + 1)))) { - *op1 = GEN_INT (i + 1); + *op1 = GEN_INT (ARM_SIGN_EXTEND (i + 1)); *code = *code == GT ? GE : LT; return; } @@ -4836,7 +4836,7 @@ arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1, if (i != ~((unsigned HOST_WIDE_INT) 0) && (const_ok_for_arm (i + 1) || const_ok_for_arm (-(i + 1)))) { - *op1 = GEN_INT (i + 1); + *op1 = GEN_INT (ARM_SIGN_EXTEND (i + 1)); *code = *code == GTU ? GEU : LTU; return; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ae89b6a5902..f2ee96dacda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-10 Kyrylo Tkachov + + PR target/65694 + * g++.dg/torture/pr65694.C: New test. + 2015-04-10 Tobias Burnus * gfortran.dg/coarray_lock_6.f90: New. diff --git a/gcc/testsuite/g++.dg/torture/pr65694.C b/gcc/testsuite/g++.dg/torture/pr65694.C new file mode 100644 index 00000000000..55e009a3167 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr65694.C @@ -0,0 +1,144 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-sign-compare -Wno-return-type -Wno-overflow" } */ +/* { dg-additional-options "-mthumb" { target arm_thumb2_ok } } */ + +struct A { + enum { __value }; +}; +template struct B { _T1 first; }; +template struct C { + typedef typename _Iterator::iterator_type iterator_type; + static iterator_type _S_base(_Iterator p1) { return p1.base(); } +}; +template +typename _RandomAccessIterator::difference_type +__distance(_RandomAccessIterator p1, _RandomAccessIterator p2, int) { + return p2 - p1; +} + +template +typename _InputIterator::difference_type distance(_InputIterator p1, + _InputIterator p2) { + return __distance(p1, p2, 0); +} + +template class D { + _Iterator _M_current; + +public: + typedef _Iterator iterator_type; + typedef int difference_type; + _Iterator base() { return _M_current; } +}; + +template +typename D<_Iterator, _Container>::difference_type +operator-(D<_Iterator, _Container> p1, D<_Iterator, _Container> p2) { + return p1.base() - p2.base(); +} + +struct F { + static unsigned short *__copy_m(unsigned short *p1, unsigned short *p2, + unsigned short *p3) { + int a = p2 - p1; + if (a) + __builtin_memmove(p3, p1, a); + return p3 + a; + } +}; +class G { +public: + void allocate(int p1) { + if (p1 > max_size()) + operator new(sizeof(short)); + } + unsigned max_size() { return -1 / sizeof(short); } +}; + +template class L : public G {}; + +struct H { + static unsigned short *allocate(int p1) { + L d; + d.allocate(p1); + } +}; +struct I { + template + static _ForwardIterator __uninit_copy(_InputIterator p1, _InputIterator p2, + _ForwardIterator p3) { + return copy(p1, p2, p3); + } +}; +struct J { + typedef unsigned short *pointer; + struct K { + unsigned short *_M_start; + unsigned short *_M_finish; + }; + J(); + J(int p1, int) { _M_create_storage(p1); } + K _M_impl; + pointer _M_allocate(unsigned p1) { p1 ? H::allocate(p1) : pointer(); } + void _M_create_storage(int p1) { _M_allocate(p1); } +}; + +C, 1>::iterator_type +__miter_base(D p1) { + return C, 1>::_S_base(p1); +} + +template +_OI __copy_move_a(_II p1, _II p2, _OI p3) { + return F::__copy_m(p1, p2, p3); +} + +template +_OI __copy_move_a2(_II p1, _II p2, _OI p3) { + return __copy_move_a<_IsMove>(p1, p2, p3); +} + +template _OI copy(_II p1, _II p2, _OI p3) { + C, 1>::iterator_type b, c = __miter_base(p1); + b = __miter_base(p2); + return __copy_move_a2(c, b, p3); +} + +template +_ForwardIterator uninitialized_copy(_InputIterator p1, _InputIterator p2, + _ForwardIterator p3) { + return I::__uninit_copy(p1, p2, p3); +} + +template +_ForwardIterator __uninitialized_copy_a(_InputIterator p1, _InputIterator p2, + _ForwardIterator p3, L<_Tp>) { + return uninitialized_copy(p1, p2, p3); +} + +class M : J { + J _Base; + +public: + M(); + M(int p1, int p2 = int()) : _Base(p1, p2) {} + M(D p1, D p2) { + _M_initialize_dispatch(p1, p2, int()); + } + D begin(); + D end(); + int size() { return _M_impl._M_finish - _M_impl._M_start; } + void _M_initialize_dispatch(D p1, + D p2, int) { + L e; + int f = distance(p1, p2); + _M_impl._M_start = _M_allocate(f); + _M_impl._M_finish = __uninitialized_copy_a(p1, p2, _M_impl._M_start, e); + } +}; + +B g, h; +void twoMeans() { + M i(g.first.begin(), h.first.end()); + M(i.size()); +} -- 2.30.2