@@ -645,6 +645,7 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
645
645
if (DemandedBits == 0 || DemandedElts == 0 )
646
646
return DAG.getUNDEF (Op.getValueType ());
647
647
648
+ bool IsLE = DAG.getDataLayout ().isLittleEndian ();
648
649
unsigned NumElts = DemandedElts.getBitWidth ();
649
650
unsigned BitWidth = DemandedBits.getBitWidth ();
650
651
KnownBits LHSKnown, RHSKnown;
@@ -664,8 +665,7 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
664
665
return DAG.getBitcast (DstVT, V);
665
666
666
667
// TODO - bigendian once we have test coverage.
667
- if (SrcVT.isVector () && (NumDstEltBits % NumSrcEltBits) == 0 &&
668
- DAG.getDataLayout ().isLittleEndian ()) {
668
+ if (IsLE && SrcVT.isVector () && (NumDstEltBits % NumSrcEltBits) == 0 ) {
669
669
unsigned Scale = NumDstEltBits / NumSrcEltBits;
670
670
unsigned NumSrcElts = SrcVT.getVectorNumElements ();
671
671
APInt DemandedSrcBits = APInt::getZero (NumSrcEltBits);
@@ -687,8 +687,7 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
687
687
}
688
688
689
689
// TODO - bigendian once we have test coverage.
690
- if ((NumSrcEltBits % NumDstEltBits) == 0 &&
691
- DAG.getDataLayout ().isLittleEndian ()) {
690
+ if (IsLE && (NumSrcEltBits % NumDstEltBits) == 0 ) {
692
691
unsigned Scale = NumSrcEltBits / NumDstEltBits;
693
692
unsigned NumSrcElts = SrcVT.isVector () ? SrcVT.getVectorNumElements () : 1 ;
694
693
APInt DemandedSrcBits = APInt::getZero (NumSrcEltBits);
@@ -802,8 +801,8 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
802
801
SDValue Src = Op.getOperand (0 );
803
802
EVT SrcVT = Src.getValueType ();
804
803
EVT DstVT = Op.getValueType ();
805
- if (DemandedElts == 1 && DstVT. getSizeInBits () == SrcVT. getSizeInBits () &&
806
- DAG. getDataLayout (). isLittleEndian () &&
804
+ if (IsLE && DemandedElts == 1 &&
805
+ DstVT. getSizeInBits () == SrcVT. getSizeInBits () &&
807
806
DemandedBits.getActiveBits () <= SrcVT.getScalarSizeInBits ()) {
808
807
return DAG.getBitcast (DstVT, Src);
809
808
}
@@ -913,6 +912,7 @@ bool TargetLowering::SimplifyDemandedBits(
913
912
if (Op.getValueType ().isScalableVector ())
914
913
return false ;
915
914
915
+ bool IsLE = TLO.DAG .getDataLayout ().isLittleEndian ();
916
916
unsigned NumElts = OriginalDemandedElts.getBitWidth ();
917
917
assert ((!Op.getValueType ().isVector () ||
918
918
NumElts == Op.getValueType ().getVectorNumElements ()) &&
@@ -1916,9 +1916,8 @@ bool TargetLowering::SimplifyDemandedBits(
1916
1916
if (DemandedBits.getActiveBits () <= InBits) {
1917
1917
// If we only need the non-extended bits of the bottom element
1918
1918
// then we can just bitcast to the result.
1919
- if (IsVecInReg && DemandedElts == 1 &&
1920
- VT.getSizeInBits () == SrcVT.getSizeInBits () &&
1921
- TLO.DAG .getDataLayout ().isLittleEndian ())
1919
+ if (IsLE && IsVecInReg && DemandedElts == 1 &&
1920
+ VT.getSizeInBits () == SrcVT.getSizeInBits ())
1922
1921
return TLO.CombineTo (Op, TLO.DAG .getBitcast (VT, Src));
1923
1922
1924
1923
unsigned Opc =
@@ -1954,9 +1953,8 @@ bool TargetLowering::SimplifyDemandedBits(
1954
1953
if (DemandedBits.getActiveBits () <= InBits) {
1955
1954
// If we only need the non-extended bits of the bottom element
1956
1955
// then we can just bitcast to the result.
1957
- if (IsVecInReg && DemandedElts == 1 &&
1958
- VT.getSizeInBits () == SrcVT.getSizeInBits () &&
1959
- TLO.DAG .getDataLayout ().isLittleEndian ())
1956
+ if (IsLE && IsVecInReg && DemandedElts == 1 &&
1957
+ VT.getSizeInBits () == SrcVT.getSizeInBits ())
1960
1958
return TLO.CombineTo (Op, TLO.DAG .getBitcast (VT, Src));
1961
1959
1962
1960
unsigned Opc =
@@ -2005,9 +2003,8 @@ bool TargetLowering::SimplifyDemandedBits(
2005
2003
2006
2004
// If we only need the bottom element then we can just bitcast.
2007
2005
// TODO: Handle ANY_EXTEND?
2008
- if (IsVecInReg && DemandedElts == 1 &&
2009
- VT.getSizeInBits () == SrcVT.getSizeInBits () &&
2010
- TLO.DAG .getDataLayout ().isLittleEndian ())
2006
+ if (IsLE && IsVecInReg && DemandedElts == 1 &&
2007
+ VT.getSizeInBits () == SrcVT.getSizeInBits ())
2011
2008
return TLO.CombineTo (Op, TLO.DAG .getBitcast (VT, Src));
2012
2009
2013
2010
APInt InDemandedBits = DemandedBits.trunc (InBits);
@@ -2170,8 +2167,7 @@ bool TargetLowering::SimplifyDemandedBits(
2170
2167
// Bitcast from a vector using SimplifyDemanded Bits/VectorElts.
2171
2168
// Demand the elt/bit if any of the original elts/bits are demanded.
2172
2169
// TODO - bigendian once we have test coverage.
2173
- if (SrcVT.isVector () && (BitWidth % NumSrcEltBits) == 0 &&
2174
- TLO.DAG .getDataLayout ().isLittleEndian ()) {
2170
+ if (IsLE && SrcVT.isVector () && (BitWidth % NumSrcEltBits) == 0 ) {
2175
2171
unsigned Scale = BitWidth / NumSrcEltBits;
2176
2172
unsigned NumSrcElts = SrcVT.getVectorNumElements ();
2177
2173
APInt DemandedSrcBits = APInt::getZero (NumSrcEltBits);
@@ -2196,8 +2192,7 @@ bool TargetLowering::SimplifyDemandedBits(
2196
2192
if (SimplifyDemandedBits (Src, DemandedSrcBits, DemandedSrcElts,
2197
2193
KnownSrcBits, TLO, Depth + 1 ))
2198
2194
return true ;
2199
- } else if ((NumSrcEltBits % BitWidth) == 0 &&
2200
- TLO.DAG .getDataLayout ().isLittleEndian ()) {
2195
+ } else if (IsLE && (NumSrcEltBits % BitWidth) == 0 ) {
2201
2196
unsigned Scale = NumSrcEltBits / BitWidth;
2202
2197
unsigned NumSrcElts = SrcVT.isVector () ? SrcVT.getVectorNumElements () : 1 ;
2203
2198
APInt DemandedSrcBits = APInt::getZero (NumSrcEltBits);
@@ -2438,6 +2433,7 @@ bool TargetLowering::SimplifyDemandedVectorElts(
2438
2433
2439
2434
SDLoc DL (Op);
2440
2435
unsigned EltSizeInBits = VT.getScalarSizeInBits ();
2436
+ bool IsLE = TLO.DAG .getDataLayout ().isLittleEndian ();
2441
2437
2442
2438
// Helper for demanding the specified elements and all the bits of both binary
2443
2439
// operands.
@@ -2513,7 +2509,7 @@ bool TargetLowering::SimplifyDemandedVectorElts(
2513
2509
// Try calling SimplifyDemandedBits, converting demanded elts to the bits
2514
2510
// of the large element.
2515
2511
// TODO - bigendian once we have test coverage.
2516
- if (TLO. DAG . getDataLayout (). isLittleEndian () ) {
2512
+ if (IsLE ) {
2517
2513
unsigned SrcEltSizeInBits = SrcVT.getScalarSizeInBits ();
2518
2514
APInt SrcDemandedBits = APInt::getZero (SrcEltSizeInBits);
2519
2515
for (unsigned i = 0 ; i != NumElts; ++i)
@@ -2826,9 +2822,8 @@ bool TargetLowering::SimplifyDemandedVectorElts(
2826
2822
KnownZero = SrcZero.zextOrTrunc (NumElts);
2827
2823
KnownUndef = SrcUndef.zextOrTrunc (NumElts);
2828
2824
2829
- if (Op.getOpcode () == ISD::ANY_EXTEND_VECTOR_INREG &&
2830
- Op.getValueSizeInBits () == Src.getValueSizeInBits () &&
2831
- DemandedSrcElts == 1 && TLO.DAG .getDataLayout ().isLittleEndian ()) {
2825
+ if (IsLE && Op.getOpcode () == ISD::ANY_EXTEND_VECTOR_INREG &&
2826
+ Op.getValueSizeInBits () == Src.getValueSizeInBits ()) {
2832
2827
// aext - if we just need the bottom element then we can bitcast.
2833
2828
return TLO.CombineTo (Op, TLO.DAG .getBitcast (VT, Src));
2834
2829
}
@@ -2841,8 +2836,8 @@ bool TargetLowering::SimplifyDemandedVectorElts(
2841
2836
2842
2837
// zext - if we just need the bottom element then we can mask:
2843
2838
// zext(and(x,c)) -> and(x,c') iff the zext is the only user of the and.
2844
- if (DemandedSrcElts == 1 && TLO. DAG . getDataLayout (). isLittleEndian () &&
2845
- Src. getOpcode () == ISD::AND && Op->isOnlyUserOf (Src.getNode ()) &&
2839
+ if (IsLE && DemandedSrcElts == 1 && Src. getOpcode () == ISD::AND &&
2840
+ Op->isOnlyUserOf (Src.getNode ()) &&
2846
2841
Op.getValueSizeInBits () == Src.getValueSizeInBits ()) {
2847
2842
SDLoc DL (Op);
2848
2843
EVT SrcVT = Src.getValueType ();
0 commit comments