From patchwork Fri Mar 28 15:29:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 334730 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 00B74140086 for ; Sat, 29 Mar 2014 02:29:18 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=Dt/B9dRlCNN4A/ooAd90mZa3Rht4T2yBAHiQPRxPDVOcLb g6YDB2mhj+TrrtFbYTVcRZ857pADgKv/O8M/Q63cbG+uQSs0WIqkQVdNFffkFk3q m3bdyeXCPZQDuIoFA0moUjjyWzVhgESYmHDEVSQ1Rt0UnT/Ya95Lf374TxWLM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=rdXdljFIsCWHD6XRoGJofT3yX2o=; b=tq4H1k1k3NPlmFaWCrso PNPpdnLEB6YeDoQl06CjvZY2icWYSs3wzEqy+O/wQe01IApyVedCNTzscsQGhZkF LVdNtNbgZ7TSMGy4QhmQ8hl4XNlcdGdEEhMSiAJu3O29N6cF28MGxwbaqKSJa7l+ l8tDhgt+pUYiE9vMMI5Al8s= Received: (qmail 4106 invoked by alias); 28 Mar 2014 15:29:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4097 invoked by uid 89); 28 Mar 2014 15:29:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, FRT_ADOBE2, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Mar 2014 15:29:09 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2SFT7Fs019356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Mar 2014 11:29:07 -0400 Received: from Mair.local (vpn-60-82.rdu2.redhat.com [10.10.60.82]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2SFT5pk016950 for ; Fri, 28 Mar 2014 11:29:06 -0400 Message-ID: <5335955B.3040204@redhat.com> Date: Fri, 28 Mar 2014 11:29:31 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR60675 X-IsSubscribed: yes The following patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60675 LRA assigned hard reg 30 to TImode subreg of DImode pseudo but it was wrong as hard reg 31 is unavailable for the allocation. The patch was bootstrapped and tested on x86-64 and aarch64. Committed as rev. 208900. 2014-03-28 Vladimir Makarov PR target/60675 * lra-assigns.c (find_hard_regno_for): Remove unavailable hard regs from checking multi-reg pseudos. 2014-03-28 Vladimir Makarov PR target/60675 * gcc.target/aarch64/pr60675.C: New. Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 208895) +++ lra-assigns.c (working copy) @@ -473,7 +473,7 @@ find_hard_regno_for (int regno, int *cos enum reg_class rclass; bitmap_iterator bi; bool *rclass_intersect_p; - HARD_REG_SET impossible_start_hard_regs; + HARD_REG_SET impossible_start_hard_regs, available_regs; COPY_HARD_REG_SET (conflict_set, lra_no_alloc_regs); rclass = regno_allocno_class_array[regno]; @@ -586,6 +586,8 @@ find_hard_regno_for (int regno, int *cos biggest_nregs = hard_regno_nregs[hard_regno][biggest_mode]; nregs_diff = (biggest_nregs - hard_regno_nregs[hard_regno][PSEUDO_REGNO_MODE (regno)]); + COPY_HARD_REG_SET (available_regs, reg_class_contents[rclass]); + AND_COMPL_HARD_REG_SET (available_regs, lra_no_alloc_regs); for (i = 0; i < rclass_size; i++) { if (try_only_hard_regno >= 0) @@ -601,9 +603,9 @@ find_hard_regno_for (int regno, int *cos && (nregs_diff == 0 || (WORDS_BIG_ENDIAN ? (hard_regno - nregs_diff >= 0 - && TEST_HARD_REG_BIT (reg_class_contents[rclass], + && TEST_HARD_REG_BIT (available_regs, hard_regno - nregs_diff)) - : TEST_HARD_REG_BIT (reg_class_contents[rclass], + : TEST_HARD_REG_BIT (available_regs, hard_regno + nregs_diff)))) { if (hard_regno_costs_check[hard_regno] Index: testsuite/gcc.target/aarch64/pr60675.C =================================================================== --- testsuite/gcc.target/aarch64/pr60675.C (revision 0) +++ testsuite/gcc.target/aarch64/pr60675.C (working copy) @@ -0,0 +1,277 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c++11 -w -O2 -fPIC" } */ +namespace CLHEP { + static const double meter = 1000.*10; + static const double meter2 = meter*meter; + static const double megaelectronvolt = 1. ; + static const double gigaelectronvolt = 1.e+3; + static const double GeV = gigaelectronvolt; + static const double megavolt = megaelectronvolt; + static const double volt = 1.e-6*megavolt; + static const double tesla = volt*1.e+9/meter2; + } + using CLHEP::GeV; + using CLHEP::tesla; + namespace std { + typedef long int ptrdiff_t; + } + extern "C" { + extern double cos (double __x) throw (); + extern double sin (double __x) throw (); + extern double sqrt (double __x) throw (); + } + namespace std __attribute__ ((__visibility__ ("default"))) { + using ::cos; + using ::sin; + using ::sqrt; + template struct char_traits; + template > struct basic_ostream; + typedef basic_ostream ostream; + template struct iterator_traits { }; + template struct iterator_traits<_Tp*> { + typedef ptrdiff_t difference_type; + typedef _Tp& reference; + }; + } + namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { + using std::iterator_traits; + template struct __normal_iterator { + _Iterator _M_current; + typedef iterator_traits<_Iterator> __traits_type; + typedef typename __traits_type::difference_type difference_type; + typedef typename __traits_type::reference reference; + explicit __normal_iterator(const _Iterator& __i) : _M_current(__i) { } + reference operator*() const { + return *_M_current; + } + __normal_iterator operator+(difference_type __n) const { + return __normal_iterator(_M_current + __n); + } + }; + template struct new_allocator { + }; + } + namespace std __attribute__ ((__visibility__ ("default"))) { + template struct allocator: public __gnu_cxx::new_allocator<_Tp> { + }; + struct ios_base { }; + template struct basic_ios : public ios_base { }; + template struct basic_ostream : virtual public basic_ios<_CharT, _Traits> { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + __ostream_type& operator<<(__ostream_type& (*__pf)(__ostream_type&)) { } + __ostream_type& operator<<(const void* __p) { + return _M_insert(__p); + } + template __ostream_type& _M_insert(_ValueT __v); + }; + template inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) { + } + } + typedef double G4double; + typedef int G4int; + extern __thread std::ostream *G4cout_p; + struct G4Field; + struct G4FieldManager { + inline G4Field* GetDetectorField() ; + }; + namespace CLHEP { + struct Hep3Vector { + Hep3Vector(double x, double y, double z); + inline ~Hep3Vector(); + inline double x() const; + inline double y() const; + inline double z() const; + inline double mag() const; + inline Hep3Vector cross(const Hep3Vector &) const; + double dx; + double dy; + double dz; + }; + Hep3Vector operator / (const Hep3Vector &, double a); + inline double Hep3Vector::x() const { + return dx; + } + inline double Hep3Vector::y() const { + return dy; + } + inline double Hep3Vector::z() const { + return dz; + } + inline Hep3Vector operator + (const Hep3Vector & a, const Hep3Vector & b) { } + inline Hep3Vector operator * (const Hep3Vector & p, double a) { } + inline double operator * (const Hep3Vector & a, const Hep3Vector & b) { } + inline Hep3Vector::Hep3Vector(double x1, double y1, double z1) : dx(x1), dy(y1), dz(z1) { + } + inline Hep3Vector::~Hep3Vector() { } + inline Hep3Vector Hep3Vector::cross(const Hep3Vector & p) const { + return Hep3Vector(dy*p.dz-p.dy*dz, dz*p.dx-p.dz*dx, dx*p.dy-p.dx*dy); + } + } + typedef CLHEP::Hep3Vector G4ThreeVector; + namespace std __attribute__ ((__visibility__ ("default"))) { + template > struct vector + { + typedef _Tp *pointer; + typedef __gnu_cxx::__normal_iterator iterator; + iterator begin() { } + }; + } + struct G4TransportationManager { + static G4TransportationManager* GetTransportationManager(); + inline G4FieldManager* GetFieldManager() const; + }; + struct G4ErrorMatrix { + G4ErrorMatrix(G4int p, G4int q, G4int i); + virtual ~G4ErrorMatrix(); + struct G4ErrorMatrix_row { + inline G4ErrorMatrix_row(G4ErrorMatrix&,G4int); + G4double & operator[](G4int); + G4ErrorMatrix& _a; + G4int _r; + }; + inline G4ErrorMatrix_row operator[] (G4int); + std::vector m; + G4int nrow, ncol; + }; + inline G4ErrorMatrix::G4ErrorMatrix_row G4ErrorMatrix::operator[] (G4int r) { + G4ErrorMatrix_row b(*this,r); + return b; + } + inline G4double &G4ErrorMatrix::G4ErrorMatrix_row::operator[](G4int c) { + return *(_a.m.begin()+_r*_a.ncol+c); + } + inline G4ErrorMatrix:: G4ErrorMatrix_row::G4ErrorMatrix_row(G4ErrorMatrix&a, G4int r) : _a(a) { + _r = r; + }; + struct G4DynamicParticle { + G4double GetCharge() const; + }; + struct G4Step; + struct G4Track { + const G4DynamicParticle* GetDynamicParticle() const; + const G4ThreeVector& GetPosition() const; + G4ThreeVector GetMomentum() const; + const G4Step* GetStep() const; + }; + struct G4StepPoint { + const G4ThreeVector& GetPosition() const; + G4ThreeVector GetMomentum() const; + }; + struct G4Step { + G4StepPoint* GetPreStepPoint() const; + G4double GetStepLength() const; + }; + namespace HepGeom { + template struct BasicVector3D { + T v_[3]; + BasicVector3D(T x1, T y1, T z1) { } + operator T * () { + return v_; + } + T x() const { + return v_[0]; + } + T y() const { + return v_[1]; + } + T z() const { + return v_[2]; + } + T perp2() const { } + T perp() const { + return std::sqrt(perp2()); + } + T mag2() const { } + T mag() const { + return std::sqrt(mag2()); + } + T theta() const { } + }; + inline BasicVector3D operator-(const BasicVector3D & a,const BasicVector3D & b) { } + inline BasicVector3D operator*(const BasicVector3D & v, double a) { } + template struct Point3D : public BasicVector3D { + explicit Point3D(const double * a) : BasicVector3D(a[0],a[1],a[2]) { } + Point3D(const CLHEP::Hep3Vector & v) : BasicVector3D(v.dx,v.dy,v.dz) { } + }; + } + typedef HepGeom::Point3D G4Point3D; + namespace HepGeom { + template struct Vector3D : public BasicVector3D { + Vector3D(const BasicVector3D & v) : BasicVector3D(v) { } + Vector3D(const CLHEP::Hep3Vector & v) : BasicVector3D(v.dx,v.dy,v.dz) { } + operator CLHEP::Hep3Vector () const { } + }; + } + typedef HepGeom::Vector3D G4Vector3D; + struct G4ErrorFreeTrajState +{ + virtual G4int PropagateError( const G4Track* aTrack ); + G4int PropagateErrorMSC( const G4Track* aTrack ); + }; + G4int G4ErrorFreeTrajState::PropagateError( const G4Track* aTrack ) { + G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/10.; + G4Point3D vposPost = aTrack->GetPosition()/10.; + G4Vector3D vpPost = aTrack->GetMomentum()/GeV; + G4Point3D vposPre = aTrack->GetStep()->GetPreStepPoint()->GetPosition()/10.; + G4Vector3D vpPre = aTrack->GetStep()->GetPreStepPoint()->GetMomentum()/GeV; + G4double pPre = vpPre.mag(); + G4double pPost = vpPost.mag(); + G4double pInvPre = 1./pPre; + G4double pInvPost = 1./pPost; + G4double deltaPInv = pInvPost - pInvPre; + G4Vector3D vpPreNorm = vpPre * pInvPre; + G4Vector3D vpPostNorm = vpPost * pInvPost; + (*G4cout_p) << "G4EP: vpPreNorm " << vpPreNorm << " vpPostNorm " << vpPostNorm << std::endl; + G4double sinpPre = std::sin( vpPreNorm.theta() ); + G4double sinpPostInv = 1./std::sin( vpPreNorm.theta() ); + G4ErrorMatrix transf(5, 5, 0 ); + G4double charge = aTrack->GetDynamicParticle()->GetCharge(); + G4double h1[3], h2[3]; + G4Field* field += G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField() +; + if( charge != 0. && field ) + { + G4ThreeVector HPre = G4ThreeVector( h1[0], h1[1], h1[2] ) / tesla *10.; + G4ThreeVector HPost= G4ThreeVector( h2[0], h2[1], h2[2] ) / tesla *10.; + { + G4double pInvAver = 1./(pInvPre + pInvPost ); + G4double CFACT8 = 2.997925E-4; + G4ThreeVector vHAverNorm( (HPre*pInvPre + HPost*pInvPost ) * pInvAver * charge * CFACT8 ); + G4double HAver = vHAverNorm.mag(); + G4double pAver = (pPre+pPost)*0.5; + G4double QAver = -HAver/pAver; + G4double thetaAver = QAver * stepLengthCm; + G4double sinThetaAver = std::sin(thetaAver); + G4double cosThetaAver = std::cos(thetaAver); + G4double gamma = vHAverNorm * vpPostNorm; + G4ThreeVector AN2 = vHAverNorm.cross( vpPostNorm ); + G4double AU = 1./vpPreNorm.perp(); + G4ThreeVector vUPre( -AU*vpPreNorm.y(), AU*vpPreNorm.x(), 0. ); + G4ThreeVector vVPre( -vpPreNorm.z()*vUPre.y(), vpPreNorm.z()*vUPre.x(), vpPreNorm.x()*vUPre.y() - vpPreNorm.y()*vUPre.x() ); + AU = 1./vpPostNorm.perp(); + G4ThreeVector vUPost( -AU*vpPostNorm.y(), AU*vpPostNorm.x(), 0. ); + G4ThreeVector vVPost( -vpPostNorm.z()*vUPost.y(), vpPostNorm.z()*vUPost.x(), vpPostNorm.x()*vUPost.y() - vpPostNorm.y()*vUPost.x() ); + G4Point3D deltaPos( vposPre - vposPost ); + G4double QP = QAver * pAver; + G4double ANV = -( vHAverNorm.x()*vUPost.x() + vHAverNorm.y()*vUPost.y() ); + G4double ANU = ( vHAverNorm.x()*vVPost.x() + vHAverNorm.y()*vVPost.y() + vHAverNorm.z()*vVPost.z() ); + G4double OMcosThetaAver = 1. - cosThetaAver; + G4double TMSINT = thetaAver - sinThetaAver; + G4ThreeVector vHUPre( -vHAverNorm.z() * vUPre.y(), vHAverNorm.z() * vUPre.x(), vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x() ); + G4ThreeVector vHVPre( vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(), vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(), vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x() ); + transf[0][1] = -deltaPInv/thetaAver* ( TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) + sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) + OMcosThetaAver*(vHVPre.x()*vpPostNorm.x()+vHVPre.y()*vpPostNorm.y()+vHVPre.z()*vpPostNorm.z()) ); + transf[0][2] = -sinpPre*deltaPInv/thetaAver* ( TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) + sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) + OMcosThetaAver*(vHUPre.x()*vpPostNorm.x()+vHUPre.y()*vpPostNorm.y()+vHUPre.z()*vpPostNorm.z()) ); + transf[0][3] = -deltaPInv/stepLengthCm*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ); + transf[1][1] = cosThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) + sinThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) + OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())* (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) + ANV*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) + OMcosThetaAver*(vVPre.x()*AN2.x()+vVPre.y()*AN2.y()+vVPre.z()*AN2.z()) - TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) ); + transf[1][2] = cosThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) + sinThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) + OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )* (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) + ANV*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) + OMcosThetaAver*(vUPre.x()*AN2.x()+vUPre.y()*AN2.y() ) - TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) ); + transf[2][0] = -QP*ANU*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())*sinpPostInv *(1.+deltaPInv*pAver); + transf[2][3] = -QAver*ANU*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() )*sinpPostInv; + transf[3][4] = (vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ); + transf[4][0] = pAver*(vVPost.x()*deltaPos.x()+vVPost.y()*deltaPos.y()+vVPost.z()*deltaPos.z()) *(1.+deltaPInv*pAver); + transf[4][1] = ( sinThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) + OMcosThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) + TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())* (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver; + transf[4][2] = ( sinThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) + OMcosThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) + TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())* (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver; + } + } + PropagateErrorMSC( aTrack ); + }