R600: Do not fold single instruction with more that 3 kcache read

It fixes around 100 tfb piglit tests and 16 glean tests.

NOTE: This is a candidate for the Mesa stable branch.

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
llvm-svn: 175183
diff --git a/llvm/lib/Target/R600/R600LowerConstCopy.cpp b/llvm/lib/Target/R600/R600LowerConstCopy.cpp
index 46f2aef..3ebe653 100644
--- a/llvm/lib/Target/R600/R600LowerConstCopy.cpp
+++ b/llvm/lib/Target/R600/R600LowerConstCopy.cpp
@@ -180,7 +180,7 @@
             int ConstMovSel =
                 TII->getOperandIdx(CstMov->getOpcode(), R600Operands::SRC0_SEL);
             unsigned ConstIndex = CstMov->getOperand(ConstMovSel).getImm();
-            if (canFoldInBundle(CP, ConstIndex)) {
+            if (MI->isInsideBundle() && canFoldInBundle(CP, ConstIndex)) {
               TII->setImmOperand(MI, OpTable[SrcOp][1], ConstIndex);
               MI->getOperand(SrcIdx).setReg(AMDGPU::ALU_CONST);
             } else {