From eb7913f1dda0f7871c1fb9d4e72d917ce2d82137 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 1 Sep 2011 15:45:49 -0700 Subject: [PATCH] AVX: fix alignment when changing masked load to regular load. Also added some debugging/tracing stuff (commented out). Commented out iffy assert that was hitting for avx stuff. --- opt.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/opt.cpp b/opt.cpp index e8a04b3e..135eb35d 100644 --- a/opt.cpp +++ b/opt.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #ifndef LLVM_2_8 #include #ifdef LLVM_2_9 @@ -69,6 +70,7 @@ #include #include #include +#include #include #include #ifndef LLVM_2_8 @@ -469,8 +471,18 @@ lGetMask(llvm::Value *factor) { else if (llvm::isa(factor)) return 0; else { +#if 0 + llvm::ConstantExpr *ce = llvm::dyn_cast(factor); + if (ce != NULL) { + llvm::TargetMachine *targetMachine = g->target.GetTargetMachine(); + const llvm::TargetData *td = targetMachine->getTargetData(); + llvm::Constant *c = llvm::ConstantFoldConstantExpression(ce, td); + c->dump(); + factor = c; + } // else we should be able to handle it above... assert(!llvm::isa(factor)); +#endif return -1; } } @@ -608,9 +620,10 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) { llvm::PointerType::get(returnType, 0), "ptr2vec", callInst); lCopyMetadata(castPtr, callInst); + int align = callInst->getCalledFunction() == avxMaskedLoad32 ? 4 : 8; llvm::Instruction *loadInst = new llvm::LoadInst(castPtr, "load", false /* not volatile */, - 0 /* align */, (llvm::Instruction *)NULL); + align, (llvm::Instruction *)NULL); lCopyMetadata(loadInst, callInst); llvm::ReplaceInstWithInst(callInst, loadInst); modifiedAny = true;