diff --git a/src/AssociativeOpsTable.cpp b/src/AssociativeOpsTable.cpp index 63b4add503e9..34fb40d93ab5 100644 --- a/src/AssociativeOpsTable.cpp +++ b/src/AssociativeOpsTable.cpp @@ -2,6 +2,7 @@ #include "IRPrinter.h" #include +#include namespace Halide { namespace Internal { @@ -93,17 +94,8 @@ struct TableKey { return (types == other.types) && (root == other.root) && (dim == other.dim); } bool operator<(const TableKey &other) const { - if (types < other.types) { - return true; - } else if (types > other.types) { - return false; - } - if (root < other.root) { - return true; - } else if (root > other.root) { - return false; - } - return (dim < other.dim); + return std::tie(types, root, dim) < + std::tie(other.types, other.root, other.dim); } }; diff --git a/src/Schedule.h b/src/Schedule.h index a72c52bbd59f..fe7eb70b23d2 100644 --- a/src/Schedule.h +++ b/src/Schedule.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -552,19 +553,9 @@ struct FusedPair { (var_name == other.var_name); } bool operator<(const FusedPair &other) const { - if (func_1 != other.func_1) { - return func_1 < other.func_1; - } - if (func_2 != other.func_2) { - return func_2 < other.func_2; - } - if (var_name != other.var_name) { - return var_name < other.var_name; - } - if (stage_1 != other.stage_1) { - return stage_1 < other.stage_1; - } - return stage_2 < other.stage_2; + return std::tie(func_1, func_2, var_name, stage_1, stage_2) < + std::tie(other.func_1, other.func_2, other.var_name, + other.stage_1, other.stage_2); } }; diff --git a/src/StageStridedLoads.cpp b/src/StageStridedLoads.cpp index 896a33b5193e..2912bbd2c726 100644 --- a/src/StageStridedLoads.cpp +++ b/src/StageStridedLoads.cpp @@ -1,4 +1,5 @@ -#include "StageStridedLoads.h" +#include + #include "CSE.h" #include "ExprUsesVar.h" #include "IREquality.h" @@ -7,6 +8,7 @@ #include "IRVisitor.h" #include "Scope.h" #include "Simplify.h" +#include "StageStridedLoads.h" #include "Substitute.h" namespace Halide { @@ -39,31 +41,15 @@ class FindStridedLoads : public IRVisitor { bool operator<(const Key &other) const { // Check fields in order of cost to compare - if (stride < other.stride) { - return true; - } else if (stride > other.stride) { - return false; - } else if (lanes < other.lanes) { - return true; - } else if (lanes > other.lanes) { - return false; - } else if (scope < other.scope) { - return true; - } else if (scope > other.scope) { - return false; - } else if (allocation < other.allocation) { - return true; - } else if (allocation > other.allocation) { - return false; - } else if (type < other.type) { - return true; - } else if (other.type < type) { - return false; - } else if (buf < other.buf) { + auto lhs = std::tie(stride, lanes, scope, allocation, type, buf); + auto rhs = std::tie(other.stride, other.lanes, other.scope, + other.allocation, other.type, other.buf); + if (lhs < rhs) { return true; - } else if (buf > other.buf) { + } else if (rhs < lhs) { return false; } else { + // base compares by graph equivalence, so it can't go in the tuple. return graph_less_than(base, other.base); } } diff --git a/src/autoschedulers/mullapudi2016/AutoSchedule.cpp b/src/autoschedulers/mullapudi2016/AutoSchedule.cpp index 9005999bf1a8..fa98b49e19ee 100644 --- a/src/autoschedulers/mullapudi2016/AutoSchedule.cpp +++ b/src/autoschedulers/mullapudi2016/AutoSchedule.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace Halide { @@ -203,22 +204,8 @@ struct DependenceAnalysis { (only_regions_computed == other.only_regions_computed); } bool operator<(const RegionsRequiredQuery &other) const { - if (f < other.f) { - return true; - } else if (f > other.f) { - return false; - } - if (stage < other.stage) { - return true; - } else if (stage > other.stage) { - return false; - } - if (only_regions_computed < other.only_regions_computed) { - return true; - } else if (only_regions_computed > other.only_regions_computed) { - return false; - } - return prods < other.prods; + return std::tie(f, stage, only_regions_computed, prods) < + std::tie(other.f, other.stage, other.only_regions_computed, other.prods); } }; struct RegionsRequired {