[PATCH] D85969: [SCEV] Model (xor (shl x, C), (-1 << C)) as (shl (xor x, -1), C)

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 05:41:20 PDT 2020


bjope created this revision.
bjope added reviewers: efriedma, spatel, lebedev.ri.
Herald added subscribers: javed.absar, hiraditya.
Herald added a project: LLVM.
bjope requested review of this revision.

InstCombine may fold a left shift over a not (xor by -1).
This patch teaches ScalarEvolution to detect such patterns, creating
a SCEV based on the reverse fold. Without this patch the instcombine
rewrite could lead to missed oppurtunities later in the pipeline
due to not being able to calculate a SCEV for the xor.

An alternative solution could be to modify InstCombine (e.g. in
canShiftBinOpWithConstantRHS) to avoid the fold that creates the
xor that isn't recognized by ScalarEvolution.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=47136


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85969

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/xor-shl.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85969.285634.patch
Type: text/x-patch
Size: 7601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200814/4a01cd5d/attachment.bin>


More information about the llvm-commits mailing list