fix a bug where the bswap matcher could match a case involving
authorChris Lattner <sabre@nondot.org>
Sun, 5 Oct 2008 00:50:57 +0000 (00:50 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 5 Oct 2008 00:50:57 +0000 (00:50 +0000)
ashr.  It should only apply to lshr.

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

lib/Transforms/Scalar/InstructionCombining.cpp

index 4f489718f6f0890b69b9700fd9b2b38bbd7d3106..95ed49d5262250c85a97b4bf6b70d437d5db0ba2 100644 (file)
@@ -3912,9 +3912,12 @@ static bool CollectBSwapParts(Value *V, SmallVector<Value*, 8> &ByteValues) {
     if (I->getOpcode() == Instruction::Shl) {
       // X << 24 defines the top byte with the lowest of the input bytes.
       DestNo = ByteValues.size()-1;
-    } else {
+    } else if (I->getOpcode() == Instruction::LShr) {
       // X >>u 24 defines the low byte with the highest of the input bytes.
       DestNo = 0;
+    } else {
+      // Arithmetic shift right may have the top bits set.
+      return true;
     }
     
     // If the destination byte value is already defined, the values are or'd