Add knowledge about the struct form of the GetElementPtr instruction
authorChris Lattner <sabre@nondot.org>
Sat, 14 Jul 2001 06:11:51 +0000 (06:11 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 14 Jul 2001 06:11:51 +0000 (06:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SCCP.cpp

index 79d90e65326b8a90891ae1a45731546673c3e8d4..63ce5125087817c2eb72919da33b8206742aff2b 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/ConstantPool.h"
 #include "llvm/InstrTypes.h"
 #include "llvm/iOther.h"
+#include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
 #include "llvm/Tools/STLExtras.h"
 #include "llvm/Assembly/Writer.h"
@@ -429,8 +430,13 @@ void SCCP::UpdateInstruction(Instruction *I) {
   
   //===-------------------------------------------------------------------===//
   // Handle Unary instructions...
+  //   Also treated as unary here, are cast instructions and getelementptr
+  //   instructions on struct* operands.
   //
-  if (I->isUnaryOp() || I->getOpcode() == Instruction::Cast) {
+  if (I->isUnaryOp() || I->getOpcode() == Instruction::Cast || 
+      (I->getOpcode() == Instruction::GetElementPtr &&
+       ((GetElementPtrInst*)I)->isStructSelector())) {
+
     Value *V = I->getOperand(0);
     InstVal &VState = getValueState(V);
     if (VState.isOverdefined()) {        // Inherit overdefinedness of operand