[llvm-dev] How to use CostModel?

Charlie Turner via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 6 08:56:57 PDT 2015

> Any other ideas?

If you have the source code, then like Navdav said, you will be able
to find LLVM instructions with a cost > 1 in

You could try some arithmetic on float data types to get things with a
cost of 2, or you can try and get the vectorizer to kick in for even
higher costs.

float foo(float in) {
  float x = 14.5 * in;
  return x;

Gives me an fmul with a cost of 2


int foo(int in[], int len) {
  for (int i = 0; i < len; i++) {
    in[i] = in[i] * 5;

gets me some instructions with a cost of 6 for example.


More information about the llvm-dev mailing list