[PATCH] D104612: [CGP][RISCV] Teach CodeGenPrepare::optimizeSwitchInst to honor isSExtCheaperThanZExt.
Jessica Clarke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 23 11:40:51 PDT 2021
jrtc27 added inline comments.
================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7014-7016
+ // Some targets prefer SExt over ZExt, honor that.
+ if (TLI->isSExtCheaperThanZExt(OldVT, RegType))
+ ExtType = Instruction::SExt;
----------------
Do we not want to avoid this in the case this is a function argument that is already being zero-extended? i.e. something like:
```
Instruction::CastOps ExtType = Instruction::CastOpsEnd;
if (auto *Arg = dyn_cast<Argument>(Cond)) {
if (Arg->hasSExtAttr())
ExtType = Instruction::SExt;
else if (Arg->hasZExtAttr())
ExtType = Instruction::ZExt;
}
if (ExtType == Instruction::CastOpsEnd) {
if (TLI->isSExtCheaperThanZExt(OldVT, RegType))
ExtType = Instruction::SExt;
else
ExtType = Instruction::ZExt;
}
```
(slightly abusing CastOpsEnd as being one past the last valid op, and thus a sentinel, though you could write it in other ways too if you wanted)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104612/new/
https://reviews.llvm.org/D104612
More information about the llvm-commits
mailing list