From: Evan Cheng Date: Sat, 24 Mar 2007 00:02:43 +0000 (+0000) Subject: Adjust offset to compensate for big endian machines. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=dae54ce7fc96be8d8d5d3a5afff856bbdf1e81a9;p=oota-llvm.git Adjust offset to compensate for big endian machines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35293 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 569b1a91d71..6187aba6405 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2292,7 +2292,6 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) { N0 = N0.getOperand(0); if (MVT::getSizeInBits(N0.getValueType()) <= EVTBits) return SDOperand(); - ShAmt /= 8; CombineSRL = true; } } @@ -2308,12 +2307,11 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) { "Cannot truncate to larger type!"); LoadSDNode *LN0 = cast(N0); MVT::ValueType PtrType = N0.getOperand(1).getValueType(); - // For big endian targets, we need to add an offset to the pointer to load - // the correct bytes. For little endian systems, we merely need to read - // fewer bytes from the same pointer. - uint64_t PtrOff = ShAmt - ? ShAmt : (TLI.isLittleEndian() ? 0 - : (MVT::getSizeInBits(N0.getValueType()) - EVTBits) / 8); + // For big endian targets, we need to adjust the offset to the pointer to + // load the correct bytes. + if (!TLI.isLittleEndian()) + ShAmt = MVT::getSizeInBits(N0.getValueType()) - ShAmt - EVTBits; + uint64_t PtrOff = ShAmt / 8; SDOperand NewPtr = DAG.getNode(ISD::ADD, PtrType, LN0->getBasePtr(), DAG.getConstant(PtrOff, PtrType)); AddToWorkList(NewPtr.Val);