Browse Source

Use i32 for GEP index. (#85)

Xiang Li 8 years ago
parent
commit
fa22112d1a
2 changed files with 4 additions and 1 deletions
  1. 3 0
      lib/HLSL/DxilGenerationPass.cpp
  2. 1 1
      tools/clang/lib/CodeGen/CGHLSLMS.cpp

+ 3 - 0
lib/HLSL/DxilGenerationPass.cpp

@@ -1296,6 +1296,9 @@ void DxilGenerationPass::GenerateDxilInputsOutputs(bool bInput) {
 
             if (ConstantInt *ColIdx = dyn_cast<ConstantInt>(info.vectorIdx)) {
               IRBuilder<> Builder(stInst);
+              if (ColIdx->getType()->getBitWidth() != 8) {
+                ColIdx = Builder.getInt8(ColIdx->getValue().getLimitedValue());
+              }
               Value *args[] = {OpArg, ID, idxVal, ColIdx, V};
               GenerateStOutput(dxilFunc, args, Builder, bI1Cast);
             } else {

+ 1 - 1
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -4742,7 +4742,7 @@ void CGMSHLSLRuntime::FlattenAggregatePtrToGepList(
     // Flatten vector too.
     QualType EltTy = hlsl::GetHLSLVecElementType(Type);
     for (uint32_t i = 0; i < VT->getNumElements(); i++) {
-      Constant *idx = CGF.Builder.getInt8(i); // CGF.Builder.getInt32(i);
+      Constant *idx = CGF.Builder.getInt32(i);
       idxList.emplace_back(idx);
 
       Value *GEP = CGF.Builder.CreateInBoundsGEP(Ptr, idxList);