1 #include "FuzzFloatStores.h"
2 #include "IRMutator.h"
3 #include "IROperator.h"
4 
5 namespace Halide {
6 namespace Internal {
7 
8 namespace {
9 class FuzzFloatStores : public IRMutator {
10     using IRMutator::visit;
11 
visit(const Store * op)12     Stmt visit(const Store *op) override {
13         Type t = op->value.type();
14         if (t.is_float()) {
15             // Drop the last bit of the mantissa.
16             Expr value = op->value;
17             Expr mask = make_one(t.with_code(Type::UInt));
18             value = reinterpret(mask.type(), value);
19             value = value & ~mask;
20             value = reinterpret(t, value);
21             return Store::make(op->name, value, op->index, op->param, op->predicate, op->alignment);
22         } else {
23             return IRMutator::visit(op);
24         }
25     }
26 };
27 }  // namespace
28 
fuzz_float_stores(const Stmt & s)29 Stmt fuzz_float_stores(const Stmt &s) {
30     return FuzzFloatStores().mutate(s);
31 }
32 
33 }  // namespace Internal
34 }  // namespace Halide
35