Various tweaks related to apint codegen. No functionality
authorDuncan Sands <baldrick@free.fr>
Mon, 9 Jun 2008 15:48:25 +0000 (15:48 +0000)
committerDuncan Sands <baldrick@free.fr>
Mon, 9 Jun 2008 15:48:25 +0000 (15:48 +0000)
change for non-funky-sized integers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52151 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/ValueTypes.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/LegalizeTypesPromote.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 22538a73d0a4ec9669ae84eac42d4a034446efad..fe3ee6e7b66a8523ca42288e997efdf4e81c9488 100644 (file)
@@ -261,6 +261,10 @@ namespace llvm {
               (isExtended() && isVector() && getSizeInBits()==128));
     }
 
+    /// isByteSized - Return true if the bit size is a multiple of 8.
+    inline bool isByteSized() const {
+      return (getSizeInBits() & 7) == 0;
+    }
 
     /// bitsGT - Return true if this has more bits than VT.
     inline bool bitsGT(MVT VT) const {
index ea96e5c9ce74886450ac339223944b815d903eac..8696bcf63b9a67632fc6d92bdb63c2f40ee3c137 100644 (file)
@@ -1785,7 +1785,7 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
           // Loading a non-byte sized integer is only valid if the extra bits
           // in memory that complete the byte are zero, which is not known here.
           // TODO: remove isSimple check when apint codegen support lands.
-          EVT.isSimple() && EVT.getSizeInBits() == EVT.getStoreSizeInBits() &&
+          EVT.isSimple() && EVT.isByteSized() &&
           (!AfterLegalize || TLI.isLoadXLegal(ISD::ZEXTLOAD, EVT))) {
         MVT PtrType = N0.getOperand(1).getValueType();
         // For big endian targets, we need to add an offset to the pointer to
@@ -3181,7 +3181,7 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) {
       // Do not allow folding to a non-byte-sized integer here.  These only
       // load correctly if the extra bits in memory that complete the byte
       // are zero, which is not known here.
-      VT.getSizeInBits() == VT.getStoreSizeInBits()) {
+      VT.isByteSized()) {
     assert(N0.getValueType().getSizeInBits() > EVTBits &&
            "Cannot truncate to larger type!");
     LoadSDNode *LN0 = cast<LoadSDNode>(N0);
index b0a8475b33bbc6a76d6d7f29a572862af7cb68d9..5c68fe2dc3d3d6fa195d2ddb1b903b5316b3d4a2 100644 (file)
@@ -94,7 +94,7 @@ SDOperand DAGTypeLegalizer::PromoteResult_Constant(SDNode *N) {
   MVT VT = N->getValueType(0);
   // Zero extend things like i1, sign extend everything else.  It shouldn't
   // matter in theory which one we pick, but this tends to give better code?
-  unsigned Opc = VT != MVT::i1 ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
+  unsigned Opc = VT.isByteSized() ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
   SDOperand Result = DAG.getNode(Opc, TLI.getTypeToTransformTo(VT),
                                  SDOperand(N, 0));
   assert(isa<ConstantSDNode>(Result) && "Didn't constant fold ext?");
index 81cdf4637fbd0e69a22a195ea28fef600da2f1db..fe752de64454c0901cebe03162d4cced14891f3f 100644 (file)
@@ -250,7 +250,7 @@ void TargetLowering::computeRegisterProperties() {
   NumRegistersForVT[MVT::isVoid] = 0;
 
   // Find the largest integer register class.
-  unsigned LargestIntReg = MVT::i128;
+  unsigned LargestIntReg = MVT::LAST_INTEGER_VALUETYPE;
   for (; RegClassForVT[LargestIntReg] == 0; --LargestIntReg)
     assert(LargestIntReg != MVT::i1 && "No integer registers defined!");