File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 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>
154154{
155155 using ImplType = TranslateIntrinsicImpl<TTranslateIntrinsic>;
156156
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+
157171 template <class SampleOrGatherInstrinsic >
158172 static bool IsApplicable (SampleOrGatherInstrinsic* sampleOrGatherIntr)
159173 {
@@ -163,9 +177,9 @@ struct TranslateIntrinsic : TranslateIntrinsicImpl<TTranslateIntrinsic>
163177 llvm::Value* offsetR = sampleOrGatherIntr->getOperand (immOffsetSourceIndex + 2 );
164178
165179 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);
169183
170184 applicable &= IsApplicableDerived<ImplType>(sampleOrGatherIntr);
171185
You can’t perform that action at this time.
0 commit comments