File tree 1 file changed +17
-3
lines changed 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,20 @@ struct TranslateIntrinsic : TranslateIntrinsicImpl<TTranslateIntrinsic>
154
154
{
155
155
using ImplType = TranslateIntrinsicImpl<TTranslateIntrinsic>;
156
156
157
+ static bool IsValidImmediateOffset (llvm::Value* offset)
158
+ {
159
+ constexpr int64_t cMinImmediateOffset = -8 ;
160
+ constexpr int64_t cMaxImmediateOffset = 7 ;
161
+ llvm::ConstantInt* imm = llvm::dyn_cast<llvm::ConstantInt>(offset);
162
+ if (imm &&
163
+ imm->getSExtValue () >= cMinImmediateOffset &&
164
+ imm->getSExtValue () <= cMaxImmediateOffset)
165
+ {
166
+ return true ;
167
+ }
168
+ return false ;
169
+ }
170
+
157
171
template <class SampleOrGatherInstrinsic >
158
172
static bool IsApplicable (SampleOrGatherInstrinsic* sampleOrGatherIntr)
159
173
{
@@ -163,9 +177,9 @@ struct TranslateIntrinsic : TranslateIntrinsicImpl<TTranslateIntrinsic>
163
177
llvm::Value* offsetR = sampleOrGatherIntr->getOperand (immOffsetSourceIndex + 2 );
164
178
165
179
bool applicable =
166
- !llvm::isa<llvm::Constant> (offsetU) ||
167
- !llvm::isa<llvm::Constant> (offsetV) ||
168
- !llvm::isa<llvm::Constant> (offsetR);
180
+ !IsValidImmediateOffset (offsetU) ||
181
+ !IsValidImmediateOffset (offsetV) ||
182
+ !IsValidImmediateOffset (offsetR);
169
183
170
184
applicable &= IsApplicableDerived<ImplType>(sampleOrGatherIntr);
171
185
You can’t perform that action at this time.
0 commit comments