[PATCH] D73607: [X86] Custom lower ISD::FROUND with SSE4.1 to avoid a libcall.

Richard Trieu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 19:07:08 PDT 2021


rtrieu added a comment.
Herald added a subscriber: pengfei.

I ran across a llvm_unreachable that points to this commit.  Repro instructions below:

test.ii

  double compare1(double x, double y) { return ((int)x< y) ? x : y; }
  double compare2(double x, double y) { return y != 0.0 ? y : x; }
  
  int compareint(int x, int y, int z) { return (x < y) ? y : (z < x) ? z : x; }
  
  class C {
  public:
    C(double arg) { 
      constexpr int k1 = -(1 << 23); 
      constexpr int k2 = (1 << 23) - 1;
      array[0] = compareint(arg, k1, k2);
    }
    
    char array[3];
  };
  extern "C" double round(double);
  constexpr double kEight = 8;
  
  C create(int b) {
    double d1 = b * kEight;
    double d2 = round(d1);
    double d3 = compare1(0.0, d2);
    double d4 = compare2(0.0, d3);
    return C(d4);
  }
  
  void loop(int* b, C *ptr, long j) {
    for (int i = 0; i < j; ++i)
      ptr[i] = create(b[i]);
  }

clang command:

  clang \
  "-cc1" \
  "-triple" "x86_64-unknown-linux-gnu" \
  "-emit-obj" \
  "-target-cpu" "x86-64" \
  "-target-feature" "+avx" \
  "-target-feature" "+avx2" \
  "-target-feature" "+avx512f" \
  "-O3" \
  "-vectorize-loops" \
  "-x" "c++" "test.ii"

output:

  PromoteIntegerResult #0: t177: v16i24 = X86ISD::VTRUNCS t216
  
  Do not know how to promote this operator!
  UNREACHABLE executed at llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:54!
  
  0.	Program arguments: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -target-cpu x86-64 -target-feature +avx -target-feature +avx2 -target-feature +avx512f -O3 -vectorize-loops -x c++ test.ii
  1.	<eof> parser at end of file
  2.	Code generation
  3.	Running pass 'Function Pass Manager' on module 'test.ii'.
  4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z4loopPiP1Cl'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73607



More information about the llvm-commits mailing list