[PATCH] D149918: [InstCombine] Add oneuse checks to shr + cmp constant folds.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 04:16:27 PDT 2023


nikic added a comment.

@aemerson You need to use the comparison as a branch condition, something like this:

  define i1 @test(i4 %x) {
    %s = ashr i4 %x, 1
    %c = icmp sgt i4 %s, 0
    br i1 %c, label %if, label %else
  if:
    %c2 = icmp sgt i4 %x, 1
    ret i1 %c2
  else:
    ret i1 false
  }

CVP will not be able to fold this anymore if the comparison isn't moved to `%x` in a multi-use scenario (for that matter, InstCombine won't either, which is something it does handle right now).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149918



More information about the llvm-commits mailing list