[llvm] r175400 - AArch64: Avoid shifts by 64, that's undefined behavior.

Benjamin Kramer benny.kra at googlemail.com
Sun Feb 17 09:55:32 PST 2013


Author: d0k
Date: Sun Feb 17 11:55:32 2013
New Revision: 175400

URL: http://llvm.org/viewvc/llvm-project?rev=175400&view=rev
Log:
AArch64: Avoid shifts by 64, that's undefined behavior.

No functionality change.

Modified:
    llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp

Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=175400&r1=175399&r2=175400&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Sun Feb 17 11:55:32 2013
@@ -2512,7 +2512,7 @@ static bool findMaskedBFI(SDValue N, SDV
     N = N.getOperand(0);
   } else {
     // Mask is the whole width.
-    Mask = (1ULL << N.getValueType().getSizeInBits()) - 1;
+    Mask = -1ULL >> (64 - N.getValueType().getSizeInBits());
   }
 
   if (N.getOpcode() == AArch64ISD::BFI) {
@@ -2590,7 +2590,7 @@ static SDValue tryCombineToBFI(SDNode *N
                             DAG.getConstant(Width, MVT::i64));
 
   // Mask is trivial
-  if ((LHSMask | RHSMask) == (1ULL << VT.getSizeInBits()) - 1)
+  if ((LHSMask | RHSMask) == (-1ULL >> (64 - VT.getSizeInBits())))
     return BFI;
 
   return DAG.getNode(ISD::AND, DL, VT, BFI,
@@ -2660,7 +2660,7 @@ static SDValue tryCombineToLargerBFI(SDN
                     BFI.getOperand(2), BFI.getOperand(3));
 
   // If the masking is trivial, we don't need to create it.
-  if ((ExtraMask | ExistingMask) == (1ULL << VT.getSizeInBits()) - 1)
+  if ((ExtraMask | ExistingMask) == (-1ULL >> (64 - VT.getSizeInBits())))
     return BFI;
 
   return DAG.getNode(ISD::AND, DL, VT, BFI,





More information about the llvm-commits mailing list