@@ -1757,9 +1757,7 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
17571757
17581758 setOperationAction (ISD::CTPOP, MVT::i64 ,
17591759 Subtarget->usePopc () ? Legal : Expand);
1760- setOperationAction (ISD::CTTZ , MVT::i64 , Expand);
1761- setOperationAction (ISD::CTLZ, MVT::i64 ,
1762- Subtarget->isVIS3 () ? Legal : LibCall);
1760+ setOperationAction (ISD::CTTZ, MVT::i64 , Expand);
17631761 setOperationAction (ISD::BSWAP, MVT::i64 , Expand);
17641762 setOperationAction (ISD::ROTL , MVT::i64 , Expand);
17651763 setOperationAction (ISD::ROTR , MVT::i64 , Expand);
@@ -1820,9 +1818,7 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
18201818 setOperationAction (ISD::FSINCOS, MVT::f32 , Expand);
18211819 setOperationAction (ISD::FREM , MVT::f32 , Expand);
18221820 setOperationAction (ISD::FMA , MVT::f32 , Expand);
1823- setOperationAction (ISD::CTTZ , MVT::i32 , Expand);
1824- setOperationAction (ISD::CTLZ, MVT::i32 ,
1825- Subtarget->isVIS3 () ? Promote : LibCall);
1821+ setOperationAction (ISD::CTTZ, MVT::i32 , Expand);
18261822 setOperationAction (ISD::ROTL , MVT::i32 , Expand);
18271823 setOperationAction (ISD::ROTR , MVT::i32 , Expand);
18281824 setOperationAction (ISD::BSWAP, MVT::i32 , Expand);
@@ -1994,8 +1990,21 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,
19941990 setOperationAction (ISD::READCYCLECOUNTER, MVT::i64 , Custom);
19951991
19961992 if (Subtarget->isVIS3 ()) {
1997- setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i32 , Promote);
1993+ setOperationAction (ISD::CTLZ, MVT::i32 , Legal);
1994+ setOperationAction (ISD::CTLZ, MVT::i64 , Legal);
1995+ setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i32 , Legal);
19981996 setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i64 , Legal);
1997+ } else if (Subtarget->usePopc ()) {
1998+ setOperationAction (ISD::CTLZ, MVT::i32 , Expand);
1999+ setOperationAction (ISD::CTLZ, MVT::i64 , Expand);
2000+ setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i32 , Expand);
2001+ setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i64 , Expand);
2002+ } else {
2003+ setOperationAction (ISD::CTLZ, MVT::i32 , Expand);
2004+ setOperationAction (ISD::CTLZ, MVT::i64 , Expand);
2005+ setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i32 ,
2006+ Subtarget->is64Bit () ? Promote : LibCall);
2007+ setOperationAction (ISD::CTLZ_ZERO_UNDEF, MVT::i64 , LibCall);
19992008 }
20002009
20012010 setOperationAction (ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
@@ -3588,6 +3597,8 @@ bool SparcTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
35883597 return false ;
35893598}
35903599
3600+ bool SparcTargetLowering::isCtlzFast () const { return Subtarget->isVIS3 (); }
3601+
35913602// Override to disable global variable loading on Linux.
35923603void SparcTargetLowering::insertSSPDeclarations (Module &M) const {
35933604 if (!Subtarget->isTargetLinux ())
0 commit comments