[PATCH] D84547: [ConstraintElimination] Add constraint elimination pass (WIP).

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 10:56:27 PDT 2020


xbolva00 added a comment.

Currently we do not optimize case like these:

  int foo_notoptimized(int a, int b)
  {
    if (b < a)
      __builtin_unreachable();
    if (a < 0)
      return -1;
    if (b < 0) // never true
      return 0;
    return 1;
  }
  
  int foo_notoptimized2(int a, int b)
  {
    if (a < 0)
      return -1;
    if (b < a)
      __builtin_unreachable();
    if (b < 0) // never true
      return 0;
    return 1;
  }
  
  int foo_notoptimized3(int a, int b)
  {
    if (b < a)
      return 2;
    if (a < 0)
      return -1;
    if (b < 0) // never true
      return 0;
    return 1;
  }

Clang does no optimization here. GCC optimizes foo_notoptimized2. Would this pass optimize those examples?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84547





More information about the llvm-commits mailing list