[all-commits] [llvm/llvm-project] b2f6cf: [InstCombine] Fold lshr/ashr(or(neg(x), x), bw-1) --...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Tue Jul 13 06:48:14 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b2f6cf14798ac738bc2c9b35bd83171e0771b7a3
      https://github.com/llvm/llvm-project/commit/b2f6cf14798ac738bc2c9b35bd83171e0771b7a3
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-07-13 (Tue, 13 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
    M llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll
    M llvm/test/Transforms/InstCombine/sub-lshr-or-to-icmp-select.ll

  Log Message:
  -----------
  [InstCombine] Fold lshr/ashr(or(neg(x),x),bw-1) --> zext/sext(icmp_ne(x,0)) (PR50816)

Handle the missing fold reported in PR50816, which is a variant of the existing ashr(sub_nsw(X,Y),bw-1) --> sext(icmp_sgt(X,Y)) fold.

We also handle the lshr(or(neg(x),x),bw-1) --> zext(icmp_ne(x,0)) equivalent - https://alive2.llvm.org/ce/z/SnZmSj

We still allow multi uses of the neg(x) - as this is likely to let us further simplify other uses of the neg - but not multi uses of the or() which would increase instruction count.

Differential Revision: https://reviews.llvm.org/D105764




More information about the All-commits mailing list