[PATCH] D25119: [CVP] Convert an AShr to a LShr if both operands are known to be nonnegative.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 12:37:05 PDT 2016


mcrosier created this revision.
mcrosier added reviewers: reames, bkramer, sanjoy.
mcrosier added subscribers: llvm-commits, haicheng.

An arithmetic shift can be safely changed to a logical shift if both operands are known positive.  This allows ComputeKnownBits (and similar analysis) to determine the sign bit of the shifted value.  In turn this allows InstCombine to canonicalize a signed comparison (a > 0) into an equality check (a != 0).

This fixes PR30577 and is the same approach taken in r263406.

Chad


https://reviews.llvm.org/D25119

Files:
  lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
  test/Transforms/CorrelatedValuePropagation/ashr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25119.73115.patch
Type: text/x-patch
Size: 3240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/90c1e95c/attachment.bin>


More information about the llvm-commits mailing list