[PATCH] D91174: [Analysis] Introduce a new InstructionCost class

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 06:57:25 PST 2020


david-arm added a comment.

OK, so it is possible to check for validity just using getValue() by writing code such as:

  assert(Cost.getValue() && "Cost is invalid");
  return Cost;

but, and perhaps this is just me, I find it a bit confusing as at first glance reading such code it seems like we're comparing a value with 0. I personally prefer using isValid() as a readable way of writing such code, but as a second option we could add a boolean operator, i.e.

  assert(Cost && "Cost is invalid");
  return Cost;

in a similar way to how other classes have done this.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91174/new/

https://reviews.llvm.org/D91174



More information about the llvm-commits mailing list