[PATCH] D64285: [InstCombine] Fold select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y) to ashr (X, Y))

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 6 07:14:46 PDT 2019


xbolva00 created this revision.
xbolva00 added reviewers: lebedev.ri, spatel.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
xbolva00 edited the summary of this revision.

(select (icmp sgt x, -1), lshr (X, Y), ashr (X, Y)) -> ashr (X, Y))
(select (icmp slt x, 1), ashr (X, Y), lshr (X, Y)) -> ashr (X, Y))

Fixes PR41173

Alive proof by @lebedev.ri (thanks)
Name: PR41173

  %cmp = icmp slt i32 %x, 1
  %shr = lshr i32 %x, %y
  %shr1 = ashr i32 %x, %y
  %retval.0 = select i1 %cmp, i32 %shr1, i32 %shr
  =>
  %retval.0 = ashr i32 %x, %y

Optimization: PR41173
Done: 1
Optimization is correct!


Repository:
  rL LLVM

https://reviews.llvm.org/D64285

Files:
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/ashr-lshr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64285.208271.patch
Type: text/x-patch
Size: 9630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190706/5af2d01b/attachment.bin>


More information about the llvm-commits mailing list