Skip to content

Commit 4fc3c3b

Browse files
authored
Add aggressive parallel merging (#262)
* Add aggressive parallel merging * New infra * bugfix * Continue * functioning * fix nostore * Compose rev
1 parent be9ee42 commit 4fc3c3b

File tree

3 files changed

+883
-142
lines changed

3 files changed

+883
-142
lines changed

include/polygeist/Ops.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,84 @@ class BarrierElim final
147147
}
148148
};
149149

150+
struct ValueOrInt {
151+
bool isValue;
152+
mlir::Value v_val;
153+
int64_t i_val;
154+
ValueOrInt(mlir::Value v) { initValue(v); }
155+
void initValue(mlir::Value v) {
156+
using namespace mlir;
157+
if (v) {
158+
IntegerAttr iattr;
159+
if (matchPattern(v, m_Constant(&iattr))) {
160+
i_val = iattr.getValue().getSExtValue();
161+
v_val = nullptr;
162+
isValue = false;
163+
return;
164+
}
165+
}
166+
isValue = true;
167+
v_val = v;
168+
}
169+
170+
ValueOrInt(size_t i) : isValue(false), v_val(), i_val(i) {}
171+
172+
bool operator>=(int64_t v) {
173+
if (isValue)
174+
return false;
175+
return i_val >= v;
176+
}
177+
bool operator>(int64_t v) {
178+
if (isValue)
179+
return false;
180+
return i_val > v;
181+
}
182+
bool operator==(int64_t v) {
183+
if (isValue)
184+
return false;
185+
return i_val == v;
186+
}
187+
bool operator<(int64_t v) {
188+
if (isValue)
189+
return false;
190+
return i_val < v;
191+
}
192+
bool operator<=(int64_t v) {
193+
if (isValue)
194+
return false;
195+
return i_val <= v;
196+
}
197+
bool operator>=(llvm::APInt v) {
198+
if (isValue)
199+
return false;
200+
return i_val >= v.getSExtValue();
201+
}
202+
bool operator>(llvm::APInt v) {
203+
if (isValue)
204+
return false;
205+
return i_val > v.getSExtValue();
206+
}
207+
bool operator==(llvm::APInt v) {
208+
if (isValue)
209+
return false;
210+
return i_val == v.getSExtValue();
211+
}
212+
bool operator<(llvm::APInt v) {
213+
if (isValue)
214+
return false;
215+
return i_val < v.getSExtValue();
216+
}
217+
bool operator<=(llvm::APInt v) {
218+
if (isValue)
219+
return false;
220+
return i_val <= v.getSExtValue();
221+
}
222+
};
223+
224+
enum class Cmp { EQ, LT, LE, GT, GE };
225+
226+
bool valueCmp(Cmp cmp, mlir::AffineExpr expr, size_t numDim,
227+
mlir::ValueRange operands, ValueOrInt val);
228+
229+
bool valueCmp(Cmp cmp, mlir::Value bval, ValueOrInt val);
150230
#endif // POLYGEISTOPS_H

0 commit comments

Comments
 (0)