diff options
| author | Tobias Grosser <tobias@grosser.es> | 2016-02-06 21:23:39 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2016-02-06 21:23:39 +0000 |
| commit | 107cd5f5f63602796cd825858bf8dfcdf53fdce2 (patch) | |
| tree | 0c0edd06c7c558881952a03274181966ff6810fe /polly/lib/CodeGen/IslNodeBuilder.cpp | |
| parent | 672808a853399b83cd308bbd73930b90a10db0de (diff) | |
| download | bcm5719-llvm-107cd5f5f63602796cd825858bf8dfcdf53fdce2.tar.gz bcm5719-llvm-107cd5f5f63602796cd825858bf8dfcdf53fdce2.zip | |
IslNodeBuilder: Invariant load hoisting of elements with differing sizes
Always use access-instruction pointer type to load the invariant values.
Otherwise mismatches between ScopArrayInfo element type and memory access
element type will result in invalid casts. These type mismatches are after
r259784 a lot more common and also arise with types of different size, which
have not been handled before.
Interestingly, this change actually simplifies the code, as we now have only
one code path that is always taken, rather then a standard code path for the
common case and a "fixup" code path that replaces the standard code path in
case of mismatching types.
llvm-svn: 260009
Diffstat (limited to 'polly/lib/CodeGen/IslNodeBuilder.cpp')
| -rw-r--r-- | polly/lib/CodeGen/IslNodeBuilder.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index 21a4e6a4980..a2a569819fc 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -900,32 +900,21 @@ Value *IslNodeBuilder::preloadUnconditionally(isl_set *AccessRange, PWAccRel = isl_pw_multi_aff_gist_params(PWAccRel, S.getContext()); isl_ast_expr *Access = isl_ast_build_access_from_pw_multi_aff(Build, PWAccRel); - Value *PreloadVal = ExprBuilder.create(Access); - - if (LoadInst *PreloadInst = dyn_cast<LoadInst>(PreloadVal)) - PreloadInst->setAlignment(dyn_cast<LoadInst>(AccInst)->getAlignment()); + auto *Address = isl_ast_expr_address_of(Access); + auto *AddressValue = ExprBuilder.create(Address); + Value *PreloadVal; // Correct the type as the SAI might have a different type than the user // expects, especially if the base pointer is a struct. Type *Ty = AccInst->getType(); - if (Ty == PreloadVal->getType()) - return PreloadVal; - if (!Ty->isFloatingPointTy() && !PreloadVal->getType()->isFloatingPointTy()) - return PreloadVal = Builder.CreateBitOrPointerCast(PreloadVal, Ty); - - // We do not want to cast floating point to non-floating point types and vice - // versa, thus we simply create a new load with a casted pointer expression. - auto *LInst = dyn_cast<LoadInst>(PreloadVal); - assert(LInst && "Preloaded value was not a load instruction"); - auto *Ptr = LInst->getPointerOperand(); - Ptr = Builder.CreatePointerCast(Ptr, Ty->getPointerTo(), - Ptr->getName() + ".cast"); - PreloadVal = Builder.CreateLoad(Ptr, LInst->getName()); + auto *Ptr = AddressValue; + auto Name = Ptr->getName(); + Ptr = Builder.CreatePointerCast(Ptr, Ty->getPointerTo(), Name + ".cast"); + PreloadVal = Builder.CreateLoad(Ptr, Name + ".load"); if (LoadInst *PreloadInst = dyn_cast<LoadInst>(PreloadVal)) PreloadInst->setAlignment(dyn_cast<LoadInst>(AccInst)->getAlignment()); - LInst->eraseFromParent(); return PreloadVal; } |

