Home | History | Annotate | Download | only in AArch64

Lines Matching defs:SExt

14 // d = sext i32 a to i64
18 // f = sext i32 b to i64
24 // Moreover, the current heuristic is simple: it does not create new sext
25 // operations, i.e., it gives up when a sext would have forked (e.g., if
82 // sext instructions.
104 /// Check if it is profitable to move a sext through this instruction.
107 /// - Inst has only one operand that will require a sext operation (we do
108 /// do not create new sext operation).
111 /// Check if it is possible and legal to move a sext through this
115 /// - Other sext operation.
119 /// Move sext operations through safe to sext instructions.
122 /// Is this sext should be considered for code motion.
123 /// We look for sext with ConsideredSExtType and uses in at least one
125 bool shouldConsiderSExt(const Instruction *SExt) const;
127 /// Collect all interesting sext operations, i.e., the ones with the right
129 /// More precisely, a sext instruction is considered as interesting if it
131 /// sext instruction that sign extended the same initial value.
163 // sext(trunc(sext)) --> sext
178 // If the type of the sext is the same as the considered one, this sext
196 // If both operands are not constant, a new sext will be created here.
198 // Therefore we don't allow to increase the number of sext even if it may
213 AArch64AddressTypePromotion::shouldConsiderSExt(const Instruction *SExt) const {
214 if (SExt->getType() != ConsideredSExtType)
217 for (const User *U : SExt->users()) {
226 // - SExtInsts contains all the sext instructions that are use direclty in
229 // - For each sext operation in SExtInsts:
230 // Let var be the operand of sext.
232 // (see canGetThrough) to move sext through var's definition:
234 // * fold var into sext uses.
235 // * move sext above var's definition.
236 // * update sext operand to use the operand of var that should be sign
241 // b = sext i32 a to i64 <- is it legal/safe/profitable to get through 'a'
245 // b = sext i32 c to i64
259 Instruction *SExt = SExtInsts.pop_back_val();
261 DEBUG(dbgs() << "Consider:\n" << *SExt << '\n');
263 // If this SExt has already been merged continue.
264 if (SExt->use_empty() && ToRemove.count(SExt)) {
270 while (auto *Inst = dyn_cast<Instruction>(SExt->getOperand(0))) {
274 // or not safe to SExt.
282 DEBUG(dbgs() << "SExt or trunc, mark it as to remove\n");
284 // assertion on the type as all involved sext operation may have not
289 assert(User && "User of sext is not an Instruction!");
290 User->setOperand(U.getOperandNo(), SExt);
293 SExt->setOperand(0, Inst->getOperand(0));
294 SExt->moveBefore(Inst);
300 // 2. Replace the uses of SExt by Inst.
304 Inst->mutateType(SExt->getType());
306 SExt->replaceAllUsesWith(Inst);
308 Instruction *SExtForOpnd = SExt;
310 DEBUG(dbgs() << "Propagate SExt to operands\n");
314 if (Inst->getOperand(OpIdx)->getType() == SExt->getType() ||
323 Inst->setOperand(OpIdx, ConstantInt::getSigned(SExt->getType(),
330 Inst->setOperand(OpIdx, UndefValue::get(SExt->getType()));
344 // If more sext are required, new instructions will have to be created.
347 if (SExtForOpnd == SExt) {
349 ToRemove.insert(SExt);
357 if (!ToRemove.count(SExt) &&
358 SExt->getType() == SExt->getOperand(0)->getType()) {
361 SExt->replaceAllUsesWith(SExt->getOperand(0));
362 ToRemove.insert(SExt);
364 ValToSExtendedUses[SExt->getOperand(0)].push_back(SExt);
422 Instruction *SExt = &II;
424 // Collect all sext operation per type.
425 if (!isa<SExtInst>(SExt) || !shouldConsiderSExt(SExt))
428 DEBUG(dbgs() << "Found:\n" << (*SExt) << '\n');
431 // 1. SExt is used in a getelementptr with more than 2 operand =>
433 // 2. The beginning of the SExt chain is SExt several time. =>
438 for (const User *U : SExt->users()) {
450 Instruction *Inst = SExt;
466 SExtInsts.push_back(SExt);
474 SeenChains[Last] = SExt;