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

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 11:35:14 PDT 2020


fhahn added a comment.

In D84547#2174106 <https://reviews.llvm.org/D84547#2174106>, @xbolva00 wrote:

> Currently we do not optimize case like these:


snip

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

Yes I think those are exactly cases this pass should optimize. Currently, signed compare are not supported, but with `a` and `b` turned into unsigned (and < 0 adjusted) simplifies the commented checks to false for `foo_notoptimized` and `foo_notoptimized3`. It doesn't for `foo_notoptimized2` currently because something introduces an `and` which is not yet supported. Also, with the current position in the pipeline, the early simplify cfg run needs to be disabled, as it removes the control flow that's used by this pass. But this is just a tangential issue.

In D84547#2174112 <https://reviews.llvm.org/D84547#2174112>, @xbolva00 wrote:

> Maybe worth to check if example posted in PR38349  could be optimized this pass or some other pass (cc @nikic)  as well.
>
> int foo(int x, int y) {
>
>   int k = x & 15;
>   if(k == 0) {
>       int p = x & 7;
>       return p == 0; // true
>   }
>   return y;
>
> }


This case is problematic, because I am not sure how bitwise ops would be integrated into the constraint system.


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