[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp
Evan Cheng
evan.cheng at apple.com
Fri Apr 7 14:53:18 PDT 2006
Changes in directory llvm/lib/Target/X86:
X86ISelLowering.cpp updated: 1.159 -> 1.160
---
Log message:
Code clean up.
---
Diffs of the changes: (+51 -141)
X86ISelLowering.cpp | 192 +++++++++++++---------------------------------------
1 files changed, 51 insertions(+), 141 deletions(-)
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.159 llvm/lib/Target/X86/X86ISelLowering.cpp:1.160
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.159 Thu Apr 6 18:23:56 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Apr 7 16:53:05 2006
@@ -1405,13 +1405,21 @@
}
/// isUndefOrInRange - Op is either an undef node or a ConstantSDNode. Return
-/// true if Op is undef or if its value falls within the specified range (L, H).
+/// true if Op is undef or if its value falls within the specified range (L, H].
static bool isUndefOrInRange(SDOperand Op, unsigned Low, unsigned Hi) {
if (Op.getOpcode() == ISD::UNDEF)
return true;
unsigned Val = cast<ConstantSDNode>(Op)->getValue();
- return (Val >= Low && Val <= Hi);
+ return (Val >= Low && Val < Hi);
+}
+
+/// isUndefOrEqual - Op is either an undef node or a ConstantSDNode. Return
+/// true if Op is undef or if its value equal to the specified value.
+static bool isUndefOrEqual(SDOperand Op, unsigned Val) {
+ if (Op.getOpcode() == ISD::UNDEF)
+ return true;
+ return cast<ConstantSDNode>(Op)->getValue() == Val;
}
/// isPSHUFDMask - Return true if the specified VECTOR_SHUFFLE operand
@@ -1473,23 +1481,14 @@
return false;
// Upper quadword copied in order.
- for (unsigned i = 4; i != 8; ++i) {
- SDOperand Arg = N->getOperand(i);
- if (Arg.getOpcode() == ISD::UNDEF) continue;
- assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Arg)->getValue() != i)
+ for (unsigned i = 4; i != 8; ++i)
+ if (!isUndefOrEqual(N->getOperand(i), i))
return false;
- }
// Lower quadword shuffled.
- for (unsigned i = 0; i != 4; ++i) {
- SDOperand Arg = N->getOperand(i);
- if (Arg.getOpcode() == ISD::UNDEF) continue;
- assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
- unsigned Val = cast<ConstantSDNode>(Arg)->getValue();
- if (Val > 4)
+ for (unsigned i = 0; i != 4; ++i)
+ if (!isUndefOrInRange(N->getOperand(i), 0, 4))
return false;
- }
return true;
}
@@ -1507,9 +1506,9 @@
// Expect bit 0 == 1, bit1 == 2
SDOperand Bit0 = N->getOperand(0);
SDOperand Bit1 = N->getOperand(1);
- if (isUndefOrInRange(Bit0, 0, 0) && isUndefOrInRange(Bit1, 3, 3))
+ if (isUndefOrEqual(Bit0, 0) && isUndefOrEqual(Bit1, 3))
return true;
- if (isUndefOrInRange(Bit0, 1, 1) && isUndefOrInRange(Bit1, 2, 2))
+ if (isUndefOrEqual(Bit0, 1) && isUndefOrEqual(Bit1, 2))
return true;
return false;
}
@@ -1544,36 +1543,10 @@
return false;
// Expect bit0 == 6, bit1 == 7, bit2 == 2, bit3 == 3
- SDOperand Bit0 = N->getOperand(0);
- SDOperand Bit1 = N->getOperand(1);
- SDOperand Bit2 = N->getOperand(2);
- SDOperand Bit3 = N->getOperand(3);
-
- if (Bit0.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit0) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit0)->getValue() != 6)
- return false;
- }
-
- if (Bit1.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit1) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit1)->getValue() != 7)
- return false;
- }
-
- if (Bit2.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit2) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit2)->getValue() != 2)
- return false;
- }
-
- if (Bit3.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit3) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit3)->getValue() != 3)
- return false;
- }
-
- return true;
+ return isUndefOrEqual(N->getOperand(0), 6) &&
+ isUndefOrEqual(N->getOperand(1), 7) &&
+ isUndefOrEqual(N->getOperand(2), 2) &&
+ isUndefOrEqual(N->getOperand(3), 3);
}
/// isMOVLHPSMask - Return true if the specified VECTOR_SHUFFLE operand
@@ -1585,36 +1558,10 @@
return false;
// Expect bit0 == 0, bit1 == 1, bit2 == 4, bit3 == 5
- SDOperand Bit0 = N->getOperand(0);
- SDOperand Bit1 = N->getOperand(1);
- SDOperand Bit2 = N->getOperand(2);
- SDOperand Bit3 = N->getOperand(3);
-
- if (Bit0.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit0) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit0)->getValue() != 0)
- return false;
- }
-
- if (Bit1.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit1) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit1)->getValue() != 1)
- return false;
- }
-
- if (Bit2.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit2) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit2)->getValue() != 4)
- return false;
- }
-
- if (Bit3.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(Bit3) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(Bit3)->getValue() != 5)
- return false;
- }
-
- return true;
+ return isUndefOrEqual(N->getOperand(0), 0) &&
+ isUndefOrEqual(N->getOperand(1), 1) &&
+ isUndefOrEqual(N->getOperand(2), 4) &&
+ isUndefOrEqual(N->getOperand(3), 5);
}
/// isMOVLPMask - Return true if the specified VECTOR_SHUFFLE operand
@@ -1626,21 +1573,13 @@
if (NumElems != 2 && NumElems != 4)
return false;
- for (unsigned i = 0; i < NumElems/2; ++i) {
- SDOperand Arg = N->getOperand(i);
- if (Arg.getOpcode() == ISD::UNDEF) continue;
- assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
- unsigned Val = cast<ConstantSDNode>(Arg)->getValue();
- if (Val != i + NumElems) return false;
- }
+ for (unsigned i = 0; i < NumElems/2; ++i)
+ if (!isUndefOrEqual(N->getOperand(i), i + NumElems))
+ return false;
- for (unsigned i = NumElems/2; i < NumElems; ++i) {
- SDOperand Arg = N->getOperand(i);
- if (Arg.getOpcode() == ISD::UNDEF) continue;
- assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
- unsigned Val = cast<ConstantSDNode>(Arg)->getValue();
- if (Val != i) return false;
- }
+ for (unsigned i = NumElems/2; i < NumElems; ++i)
+ if (!isUndefOrEqual(N->getOperand(i), i))
+ return false;
return true;
}
@@ -1654,20 +1593,14 @@
if (NumElems != 2 && NumElems != 4)
return false;
- for (unsigned i = 0; i < NumElems/2; ++i) {
- SDOperand Arg = N->getOperand(i);
- if (Arg.getOpcode() == ISD::UNDEF) continue;
- assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
- unsigned Val = cast<ConstantSDNode>(Arg)->getValue();
- if (Val != i) return false;
- }
+ for (unsigned i = 0; i < NumElems/2; ++i)
+ if (!isUndefOrEqual(N->getOperand(i), i))
+ return false;
for (unsigned i = 0; i < NumElems/2; ++i) {
SDOperand Arg = N->getOperand(i + NumElems/2);
- if (Arg.getOpcode() == ISD::UNDEF) continue;
- assert(isa<ConstantSDNode>(Arg) && "Invalid VECTOR_SHUFFLE mask!");
- unsigned Val = cast<ConstantSDNode>(Arg)->getValue();
- if (Val != i + NumElems) return false;
+ if (!isUndefOrEqual(Arg, i + NumElems))
+ return false;
}
return true;
@@ -1685,18 +1618,10 @@
for (unsigned i = 0, j = 0; i != NumElems; i += 2, ++j) {
SDOperand BitI = N->getOperand(i);
SDOperand BitI1 = N->getOperand(i+1);
-
- if (BitI.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(BitI) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(BitI)->getValue() != j)
- return false;
- }
-
- if (BitI1.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(BitI1) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(BitI1)->getValue() != j + NumElems)
- return false;
- }
+ if (!isUndefOrEqual(BitI, j))
+ return false;
+ if (!isUndefOrEqual(BitI1, j + NumElems))
+ return false;
}
return true;
@@ -1714,18 +1639,10 @@
for (unsigned i = 0, j = 0; i != NumElems; i += 2, ++j) {
SDOperand BitI = N->getOperand(i);
SDOperand BitI1 = N->getOperand(i+1);
-
- if (BitI.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(BitI) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(BitI)->getValue() != j + NumElems/2)
- return false;
- }
-
- if (BitI1.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(BitI1) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(BitI1)->getValue() != j + NumElems/2 + NumElems)
- return false;
- }
+ if (!isUndefOrEqual(BitI, j + NumElems/2))
+ return false;
+ if (!isUndefOrEqual(BitI1, j + NumElems/2 + NumElems))
+ return false;
}
return true;
@@ -1745,17 +1662,10 @@
SDOperand BitI = N->getOperand(i);
SDOperand BitI1 = N->getOperand(i+1);
- if (BitI.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(BitI) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(BitI)->getValue() != j)
- return false;
- }
-
- if (BitI1.getOpcode() != ISD::UNDEF) {
- assert(isa<ConstantSDNode>(BitI1) && "Invalid VECTOR_SHUFFLE mask!");
- if (cast<ConstantSDNode>(BitI1)->getValue() != j)
- return false;
- }
+ if (!isUndefOrEqual(BitI, j))
+ return false;
+ if (!isUndefOrEqual(BitI1, j))
+ return false;
}
return true;
@@ -1923,11 +1833,11 @@
if (isScalarLoadToVector(V1)) {
unsigned NumElems = Mask.getNumOperands();
for (unsigned i = 0, e = NumElems/2; i != e; ++i)
- if (!isUndefOrInRange(Mask.getOperand(i), i, i))
+ if (!isUndefOrEqual(Mask.getOperand(i), i))
return false;
for (unsigned i = NumElems/2; i != NumElems; ++i)
if (!isUndefOrInRange(Mask.getOperand(i),
- NumElems+NumElems/2, NumElems*2-1))
+ NumElems+NumElems/2, NumElems*2))
return false;
return true;
}
@@ -1944,10 +1854,10 @@
unsigned NumElems = Op.getNumOperands();
for (unsigned i = 0, e = NumElems/2; i != e; ++i)
- if (!isUndefOrInRange(Op.getOperand(i), NumElems, NumElems*2-1))
+ if (!isUndefOrInRange(Op.getOperand(i), NumElems, NumElems*2))
return false;
for (unsigned i = NumElems/2; i != NumElems; ++i)
- if (!isUndefOrInRange(Op.getOperand(i), 0, NumElems-1))
+ if (!isUndefOrInRange(Op.getOperand(i), 0, NumElems))
return false;
return true;
}
More information about the llvm-commits
mailing list