From ad9e66650d2c620133770eb5eb627732b9245f18 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 29 Aug 2011 16:58:48 -0700 Subject: [PATCH] AVX bugfix with alignment for store instructions. When replacing 'all on' masked store with regular store, set alignment to be the vector element alignment, not the alignment for a whole vector. (i.e. 4 or 8 byte alignment, not 32 or 64). --- opt.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opt.cpp b/opt.cpp index 6d6c3d95..05109806 100644 --- a/opt.cpp +++ b/opt.cpp @@ -637,10 +637,14 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) { llvm::PointerType::get(storeType, 0), "ptr2vec", callInst); lCopyMetadata(castPtr, callInst); - llvm::Instruction *storeInst = + + llvm::StoreInst *storeInst = new llvm::StoreInst(rvalue, castPtr, (llvm::Instruction *)NULL); + int align = callInst->getCalledFunction() == avxMaskedStore32 ? 4 : 8; + storeInst->setAlignment(align); lCopyMetadata(storeInst, callInst); llvm::ReplaceInstWithInst(callInst, storeInst); + modifiedAny = true; goto restart; }