Skip to content

Commit 3b046ea

Browse files
Convert some Intrinsic calls to PureIntrinsic (#6070)
* Convert some Intrinsic calls to PureIntrinsic * Fixes
1 parent d2ca93a commit 3b046ea

8 files changed

+22
-22
lines changed

src/CodeGen_Hexagon.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class SloppyUnpredicateLoadsAndStores : public IRMutator {
277277
const_true(op->type.lanes()), op->alignment);
278278

279279
return Call::make(op->type, Call::if_then_else,
280-
{condition, load, make_zero(op->type)}, Call::Intrinsic);
280+
{condition, load, make_zero(op->type)}, Call::PureIntrinsic);
281281
} else {
282282
// It's a predicated vector gather. Just scalarize. We'd
283283
// prefer to keep it in a loop, but that would require
@@ -287,7 +287,7 @@ class SloppyUnpredicateLoadsAndStores : public IRMutator {
287287
Expr load = Load::make(op->type, op->name, index, op->image, op->param,
288288
const_true(op->type.lanes()), op->alignment);
289289
return Call::make(op->type, Call::if_then_else,
290-
{predicate, load, make_zero(op->type)}, Call::Intrinsic);
290+
{predicate, load, make_zero(op->type)}, Call::PureIntrinsic);
291291
}
292292
}
293293

@@ -2099,7 +2099,7 @@ void CodeGen_Hexagon::visit(const Select *op) {
20992099
// Implement scalar conditions on vector values with if-then-else.
21002100
value = codegen(Call::make(op->type, Call::if_then_else,
21012101
{op->condition, op->true_value, op->false_value},
2102-
Call::Intrinsic));
2102+
Call::PureIntrinsic));
21032103
} else {
21042104
CodeGen_Posix::visit(op);
21052105
}

src/CodeGen_Internal.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ Expr lower_euclidean_div(Expr a, Expr b) {
464464
if (!can_prove(!b_is_const_zero)) {
465465
b = b | cast(a.type(), b_is_const_zero);
466466
}
467-
q = Call::make(a.type(), Call::div_round_to_zero, {a, b}, Call::Intrinsic);
467+
q = Call::make(a.type(), Call::div_round_to_zero, {a, b}, Call::PureIntrinsic);
468468
q = select(b_is_const_zero, 0, q);
469469
} else {
470470
internal_assert(a.type().is_int());
@@ -506,7 +506,7 @@ Expr lower_euclidean_div(Expr a, Expr b) {
506506
// If a is negative, add one to it to get the rounding to work out.
507507
a -= a_neg;
508508
// Do the C-style division
509-
q = Call::make(a.type(), Call::div_round_to_zero, {a, b}, Call::Intrinsic);
509+
q = Call::make(a.type(), Call::div_round_to_zero, {a, b}, Call::PureIntrinsic);
510510
// If a is negative, either add or subtract one, depending on
511511
// the sign of b, to fix the rounding. This can't overflow,
512512
// because we move the result towards zero in either case (we
@@ -530,7 +530,7 @@ Expr lower_euclidean_mod(Expr a, Expr b) {
530530
if (!can_prove(!b_is_const_zero)) {
531531
b = b | cast(a.type(), b_is_const_zero);
532532
}
533-
q = Call::make(a.type(), Call::mod_round_to_zero, {a, b}, Call::Intrinsic);
533+
q = Call::make(a.type(), Call::mod_round_to_zero, {a, b}, Call::PureIntrinsic);
534534
q = select(b_is_const_zero, make_zero(a.type()), q);
535535
} else {
536536
internal_assert(a.type().is_int());
@@ -560,7 +560,7 @@ Expr lower_euclidean_mod(Expr a, Expr b) {
560560
// If a is negative, add one to get the rounding to work out
561561
a -= a_neg;
562562
// Do the mod, avoiding taking mod by zero
563-
q = Call::make(a.type(), Call::mod_round_to_zero, {a, (b | b_zero)}, Call::Intrinsic);
563+
q = Call::make(a.type(), Call::mod_round_to_zero, {a, (b | b_zero)}, Call::PureIntrinsic);
564564
// If a is negative, we either need to add b - 1 to the
565565
// result, or -b - 1, depending on the sign of b.
566566
q += (a_neg & ((b ^ b_neg) + ~b_neg));

src/CodeGen_LLVM.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ void CodeGen_LLVM::codegen_predicated_vector_load(const Load *op) {
23732373
Expr pred_load = Call::make(load_expr.type(),
23742374
Call::if_then_else,
23752375
{op->predicate, load_expr, make_zero(load_expr.type())},
2376-
Internal::Call::Intrinsic);
2376+
Internal::Call::PureIntrinsic);
23772377
value = codegen(pred_load);
23782378
}
23792379
}
@@ -2963,7 +2963,7 @@ void CodeGen_LLVM::visit(const Call *op) {
29632963
value = create_alloca_at_entry(halide_buffer_t_type, 1);
29642964
} else {
29652965
const int64_t *sz = as_const_int(op->args[0]);
2966-
internal_assert(sz);
2966+
internal_assert(sz != nullptr);
29672967
if (op->type == type_of<struct halide_dimension_t *>()) {
29682968
value = create_alloca_at_entry(dimension_t_type, *sz / sizeof(halide_dimension_t));
29692969
} else {

src/FuseGPUThreadLoops.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class ExtractSharedAndHeapAllocations : public IRMutator {
357357
// it's not exact.
358358
debug(1)
359359
<< "Shared allocation for " << s.name
360-
<< " has a size that is non-monontonic in the gpu block variable " << op->name
360+
<< " has a size that is non-monotonic in the gpu block variable " << op->name
361361
<< ": " << s.size << "\n";
362362
if (get_compiler_logger()) {
363363
get_compiler_logger()->record_non_monotonic_loop_var(op->name, s.size);

src/IROperator.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Expr stringify(const std::vector<Expr> &args) {
5858
}
5959

6060
return Internal::Call::make(type_of<const char *>(), Internal::Call::stringify,
61-
args, Internal::Call::Intrinsic);
61+
args, Internal::Call::PureIntrinsic);
6262
}
6363

6464
Expr combine_strings(const std::vector<Expr> &args) {
@@ -1499,7 +1499,7 @@ Expr mux(const Expr &id, const std::vector<Expr> &values) {
14991499
}
15001500
std::vector<Expr> result{id};
15011501
result.insert(result.end(), values.begin(), values.end());
1502-
return Internal::Call::make(t, Internal::Call::mux, result, Internal::Call::Intrinsic);
1502+
return Internal::Call::make(t, Internal::Call::mux, result, Internal::Call::PureIntrinsic);
15031503
}
15041504

15051505
Expr mux(const Expr &id, const Tuple &tup) {
@@ -2509,7 +2509,7 @@ Expr div_round_to_zero(Expr x, Expr y) {
25092509
Type t = x.type();
25102510
return Internal::Call::make(t, Internal::Call::div_round_to_zero,
25112511
{std::move(x), std::move(y)},
2512-
Internal::Call::Intrinsic);
2512+
Internal::Call::PureIntrinsic);
25132513
}
25142514

25152515
Expr mod_round_to_zero(Expr x, Expr y) {
@@ -2524,7 +2524,7 @@ Expr mod_round_to_zero(Expr x, Expr y) {
25242524
Type t = x.type();
25252525
return Internal::Call::make(t, Internal::Call::mod_round_to_zero,
25262526
{std::move(x), std::move(y)},
2527-
Internal::Call::Intrinsic);
2527+
Internal::Call::PureIntrinsic);
25282528
}
25292529

25302530
Expr random_float(Expr seed) {

src/Simplify_Call.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ Expr Simplify::visit(const Call *op, ExprInfo *bounds) {
690690
if (unchanged) {
691691
return op;
692692
} else {
693-
return Call::make(op->type, Call::mux, mutated_args, op->call_type);
693+
return Call::make(op->type, Call::mux, mutated_args, Call::PureIntrinsic);
694694
}
695695
} else if (op->call_type == Call::PureExtern) {
696696
// TODO: This could probably be simplified into a single map-lookup

src/Tracing.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ Stmt inject_tracing(Stmt s, const string &pipeline_name, bool trace_pipeline,
457457
Internal::Call::make(type_of<const char *>(),
458458
Internal::Call::stringify,
459459
strings,
460-
Internal::Call::Intrinsic);
460+
Internal::Call::PureIntrinsic);
461461
s = Block::make(Evaluate::make(builder.build()), s);
462462
}
463463

test/correctness/simplify.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -2102,10 +2102,10 @@ void check_unreachable() {
21022102
check(IfThenElse::make(x != 0, Evaluate::make(unreachable()), not_no_op(y)),
21032103
not_no_op(y));
21042104

2105-
check(y + Call::make(Int(32), Call::if_then_else, {x != 0, unreachable(), unreachable()}, Call::Intrinsic),
2105+
check(y + Call::make(Int(32), Call::if_then_else, {x != 0, unreachable(), unreachable()}, Call::PureIntrinsic),
21062106
unreachable());
2107-
check(Call::make(Int(32), Call::if_then_else, {x != 0, y, unreachable()}, Call::Intrinsic), y);
2108-
check(Call::make(Int(32), Call::if_then_else, {x != 0, unreachable(), y}, Call::Intrinsic), y);
2107+
check(Call::make(Int(32), Call::if_then_else, {x != 0, y, unreachable()}, Call::PureIntrinsic), y);
2108+
check(Call::make(Int(32), Call::if_then_else, {x != 0, unreachable(), y}, Call::PureIntrinsic), y);
21092109

21102110
check(Block::make(not_no_op(y), For::make("i", 0, 1, ForType::Serial, DeviceAPI::None, Evaluate::make(unreachable()))),
21112111
Evaluate::make(unreachable()));
@@ -2130,11 +2130,11 @@ int main(int argc, char **argv) {
21302130
Expr x = Var("x"), y = Var("y");
21312131

21322132
// Check that constant args to a stringify get combined
2133-
check(Call::make(type_of<const char *>(), Call::stringify, {3, std::string(" "), 4}, Call::Intrinsic),
2133+
check(Call::make(type_of<const char *>(), Call::stringify, {3, std::string(" "), 4}, Call::PureIntrinsic),
21342134
std::string("3 4"));
21352135

2136-
check(Call::make(type_of<const char *>(), Call::stringify, {3, x, 4, std::string(", "), 3.4f}, Call::Intrinsic),
2137-
Call::make(type_of<const char *>(), Call::stringify, {std::string("3"), x, std::string("4, 3.400000")}, Call::Intrinsic));
2136+
check(Call::make(type_of<const char *>(), Call::stringify, {3, x, 4, std::string(", "), 3.4f}, Call::PureIntrinsic),
2137+
Call::make(type_of<const char *>(), Call::stringify, {std::string("3"), x, std::string("4, 3.400000")}, Call::PureIntrinsic));
21382138

21392139
{
21402140
// Check that contiguous prefetch call get collapsed

0 commit comments

Comments
 (0)