@@ -186,10 +186,13 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
186
186
}
187
187
188
188
auto &ConstantActions = getActionDefinitionsBuilder (G_CONSTANT);
189
+ ConstantActions
190
+ .legalFor ({s32, p0})
189
191
if (ST.is64Bit ())
190
192
ConstantActions.customFor ({s64});
191
- ConstantActions.legalFor ({s32, p0}).widenScalarToNextPow2 (0 ).clampScalar (
192
- 0 , s32, sXLen );
193
+ ConstantActions
194
+ .widenScalarToNextPow2 (0 )
195
+ .clampScalar (0 , s32, sXLen );
193
196
194
197
getActionDefinitionsBuilder (G_IMPLICIT_DEF)
195
198
.legalFor ({s32, sXLen , p0})
@@ -461,10 +464,10 @@ bool RISCVLegalizerInfo::legalizeVAStart(MachineInstr &MI,
461
464
}
462
465
463
466
bool RISCVLegalizerInfo::shouldBeInConstantPool (APInt APImm,
464
- bool shouldOptForSize ) const {
467
+ bool ShouldOptForSize ) const {
465
468
unsigned BitWidth = APImm.getBitWidth ();
466
469
assert (BitWidth == 32 || BitWidth == 64 );
467
- uint64_t Imm = APImm.getZExtValue ();
470
+ uint64_t Imm = APImm.getSExtValue ();
468
471
// All simm32 constants should be handled by isel.
469
472
// NOTE: The getMaxBuildIntsCost call below should return a value >= 2 making
470
473
// this check redundant, but small immediates are common so this check
@@ -482,7 +485,7 @@ bool RISCVLegalizerInfo::shouldBeInConstantPool(APInt APImm,
482
485
483
486
// Optimizations below are disabled for opt size. If we're optimizing for
484
487
// size, use a constant pool.
485
- if (shouldOptForSize )
488
+ if (ShouldOptForSize )
486
489
return true ;
487
490
//
488
491
// Special case. See if we can build the constant as (ADD (SLLI X, C), X) do
@@ -493,10 +496,7 @@ bool RISCVLegalizerInfo::shouldBeInConstantPool(APInt APImm,
493
496
unsigned ShiftAmt, AddOpc;
494
497
RISCVMatInt::InstSeq SeqLo =
495
498
RISCVMatInt::generateTwoRegInstSeq (Imm, STI, ShiftAmt, AddOpc);
496
- if (!SeqLo.empty () && (SeqLo.size () + 2 ) <= STI.getMaxBuildIntsCost ())
497
- return false ;
498
-
499
- return true ;
499
+ return !(!SeqLo.empty () && (SeqLo.size () + 2 ) <= STI.getMaxBuildIntsCost ());
500
500
}
501
501
502
502
// TODO: This is almost the same as LegalizerHelper::lowerFConstant and is
@@ -512,7 +512,7 @@ bool RISCVLegalizerInfo::emitLoadFromConstantPool(
512
512
LLT AddrPtrTy = LLT::pointer (AddrSpace, DL.getPointerSizeInBits (AddrSpace));
513
513
LLT DstLLT = MRI.getType (DstReg);
514
514
515
- Align Alignment = Align (DL.getABITypeAlign (getTypeForLLT (DstLLT, Ctx)));
515
+ Align Alignment (DL.getABITypeAlign (getTypeForLLT (DstLLT, Ctx)));
516
516
517
517
auto Addr = MIRBuilder.buildConstantPool (
518
518
AddrPtrTy,
@@ -542,9 +542,9 @@ bool RISCVLegalizerInfo::legalizeCustom(
542
542
const Function &F = MF.getFunction ();
543
543
// TODO: if PSI and BFI are present, add " ||
544
544
// llvm::shouldOptForSize(*CurMBB, PSI, BFI)".
545
- bool shouldOptForSize = F.hasOptSize () || F.hasMinSize ();
545
+ bool ShouldOptForSize = F.hasOptSize () || F.hasMinSize ();
546
546
const ConstantInt *ConstVal = MI.getOperand (1 ).getCImm ();
547
- if (!shouldBeInConstantPool (ConstVal->getValue (), shouldOptForSize ))
547
+ if (!shouldBeInConstantPool (ConstVal->getValue (), ShouldOptForSize ))
548
548
return true ;
549
549
emitLoadFromConstantPool (MI.getOperand (0 ).getReg (),
550
550
MI.getOperand (1 ).getCImm (), MIRBuilder);
0 commit comments