[PATCH] D84664: [InstCombine] Fold shift-select if all the operands are constant

Matteo Favaro via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 02:30:13 PDT 2020


fvrmatteo added a comment.

> Please just post IR inline, it's super inconvient to extract it from attachmensts

Took note of this, sorry!

> As i suspected, the alive-tv result is red herring

Is it? I may be doing something wrong but if I take the optimised code for the i64 version:

  define i64 @fold_lshr(i1 %arg) {
  entry:
    %v0 = zext i1 %arg to i64
    %0 = or i64 %v0, 8589934590
    %v2.neg = add nuw nsw i64 %0, 1
    %v6 = and i64 %v2.neg, 5369111591
    ret i64 %v6
  }

and substitute the values **false** and **true** to %arg I get wrong values (5369111591 and 0) instead of the expected values (5369111591 and 5369111361) that are obtained if **false** and **true** are substituted in the unoptimised code.

I'm confused now, I don't know if I'm seeing things or doing wrong assumptions. Would you be able to prove the i64 example with Alive2 (with no `--disable-undef-input`) or to replicate my tests with **false** and **true**, please?


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

https://reviews.llvm.org/D84664



More information about the llvm-commits mailing list