File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,32 @@ Value* get_operand(llvm::Value *v,
286286 if (!ty)
287287 return nullptr ;
288288
289+ // automatic splat of constant values
290+ if (auto vty = dyn_cast<llvm::FixedVectorType>(v->getType ());
291+ vty && !isa<llvm::ConstantAggregate, llvm::ConstantAggregateZero,
292+ llvm::ConstantDataSequential>(v)) {
293+ llvm::Value *llvm_splat = nullptr ;
294+ if (auto cnst = dyn_cast<llvm::ConstantInt>(v)) {
295+ llvm_splat
296+ = llvm::ConstantInt::get (vty->getElementType (), cnst->getValue ());
297+ } else if (auto cnst = dyn_cast<llvm::ConstantFP>(v)) {
298+ llvm_splat
299+ = llvm::ConstantFP::get (vty->getElementType (), cnst->getValue ());
300+ } else
301+ return nullptr ;
302+
303+ auto splat = get_operand (llvm_splat, constexpr_conv, copy_inserter,
304+ register_fn_decl);
305+ if (!splat)
306+ return nullptr ;
307+
308+ vector<Value*> vals (vty->getNumElements (), splat);
309+ auto val = make_unique<AggregateValue>(*ty, std::move (vals));
310+ auto ret = val.get ();
311+ current_fn->addConstant (std::move (val));
312+ RETURN_CACHE (ret);
313+ }
314+
289315 if (auto cnst = dyn_cast<llvm::ConstantInt>(v)) {
290316 RETURN_CACHE (make_intconst (cnst->getValue ()));
291317 }
You can’t perform that action at this time.
0 commit comments