-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV] Fix shift instruction opcodes in getArithmeticInstrCost #156335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
steven-studio
wants to merge
2
commits into
llvm:main
Choose a base branch
from
steven-studio:riscv-fix-shifts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,14 +85,14 @@ RISCVTTIImpl::getRISCVInstructionCost(ArrayRef<unsigned> OpCodes, MVT VT, | |
case RISCV::VFREDUSUM_VS: { | ||
unsigned VL = VT.getVectorMinNumElements(); | ||
if (!VT.isFixedLengthVector()) | ||
VL *= *getVScaleForTuning(); | ||
VL *= getVScaleForTuning().value_or(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change isn't mentioned in the description? |
||
Cost += Log2_32_Ceil(VL); | ||
break; | ||
} | ||
case RISCV::VFREDOSUM_VS: { | ||
unsigned VL = VT.getVectorMinNumElements(); | ||
if (!VT.isFixedLengthVector()) | ||
VL *= *getVScaleForTuning(); | ||
VL *= getVScaleForTuning().value_or(1); | ||
Cost += VL; | ||
break; | ||
} | ||
|
@@ -242,7 +242,7 @@ InstructionCost RISCVTTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx, | |
// One more or less than a power of 2 can use SLLI+ADD/SUB. | ||
if ((Imm + 1).isPowerOf2() || (Imm - 1).isPowerOf2()) | ||
return TTI::TCC_Free; | ||
// FIXME: There is no MULI instruction. | ||
// No MULI in RISC-V, but 12-bit immediates can still be used in sequences. | ||
Takes12BitImm = true; | ||
break; | ||
case Instruction::Sub: | ||
|
@@ -1342,7 +1342,7 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, | |
Op = RISCV::VSADD_VV; | ||
break; | ||
case Intrinsic::ssub_sat: | ||
Op = RISCV::VSSUBU_VV; | ||
Op = RISCV::VSSUB_VV; | ||
break; | ||
case Intrinsic::uadd_sat: | ||
Op = RISCV::VSADDU_VV; | ||
|
@@ -1766,7 +1766,7 @@ unsigned RISCVTTIImpl::getEstimatedVLFor(VectorType *Ty) const { | |
if (isa<ScalableVectorType>(Ty)) { | ||
const unsigned EltSize = DL.getTypeSizeInBits(Ty->getElementType()); | ||
const unsigned MinSize = DL.getTypeSizeInBits(Ty).getKnownMinValue(); | ||
const unsigned VectorBits = *getVScaleForTuning() * RISCV::RVVBitsPerBlock; | ||
const unsigned VectorBits = getVScaleForTuning().value_or(1) * RISCV::RVVBitsPerBlock; | ||
return RISCVTargetLowering::computeVLMAX(VectorBits, EltSize, MinSize); | ||
} | ||
return cast<FixedVectorType>(Ty)->getNumElements(); | ||
|
@@ -2510,9 +2510,13 @@ InstructionCost RISCVTTIImpl::getArithmeticInstrCost( | |
Op = RISCV::VADD_VV; | ||
break; | ||
case ISD::SHL: | ||
Op = RISCV::VSLL_VV; | ||
break; | ||
case ISD::SRL: | ||
Op = RISCV::VSRL_VV; | ||
break; | ||
case ISD::SRA: | ||
Op = RISCV::VSLL_VV; | ||
Op = RISCV::VSRA_VV; | ||
break; | ||
case ISD::AND: | ||
case ISD::OR: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this change?