@@ -158,7 +158,7 @@ static void generateInstSeqImpl(int64_t Val, const MCSubtargetInfo &STI,
158
158
// Reduce the shift amount and add zeros to the LSBs so it will match
159
159
// LUI, then shift left with SLLI.UW to clear the upper 32 set bits.
160
160
ShiftAmount -= 12 ;
161
- Val = ((uint64_t )Val << 12 ) | ( 0xffffffffull << 32 );
161
+ Val = SignExtend64< 32 > ((uint64_t )Val << 12 );
162
162
Unsigned = true ;
163
163
}
164
164
}
@@ -168,7 +168,7 @@ static void generateInstSeqImpl(int64_t Val, const MCSubtargetInfo &STI,
168
168
STI.hasFeature (RISCV::FeatureStdExtZba)) {
169
169
// Use LUI+ADDI or LUI to compose, then clear the upper 32 bits with
170
170
// SLLI_UW.
171
- Val = ((uint64_t )Val) | ( 0xffffffffull << 32 );
171
+ Val = SignExtend64< 32 > ((uint64_t )Val);
172
172
Unsigned = true ;
173
173
}
174
174
}
@@ -239,8 +239,8 @@ static void generateInstSeqLeadingZeros(int64_t Val, const MCSubtargetInfo &STI,
239
239
// If we have exactly 32 leading zeros and Zba, we can try using zext.w at
240
240
// the end of the sequence.
241
241
if (LeadingZeros == 32 && STI.hasFeature (RISCV::FeatureStdExtZba)) {
242
- // Try replacing upper bits with 1 .
243
- uint64_t LeadingOnesVal = Val | maskLeadingOnes< uint64_t >(LeadingZeros );
242
+ // Bit 31 is set, so sign extend to fill the upper bits with 1s .
243
+ uint64_t LeadingOnesVal = SignExtend64< 32 >(Val );
244
244
TmpSeq.clear ();
245
245
generateInstSeqImpl (LeadingOnesVal, STI, TmpSeq);
246
246
0 commit comments