[PATCH] D90734: [EarlyCSE] make abs recognization not depend on instcombine abs canonicalize

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 21:35:31 PST 2020


shchenz created this revision.
shchenz added reviewers: spatel, nikic, JosephTremoulet, lebedev.ri, jsji, steven.zhang.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
shchenz requested review of this revision.

EarlyCSE pass runs very early at the pipeline of opt binary, before inst combine pass.

For now EarlyCSE pass only recognizes the abs pattern after the canonicalize of abs in instcombine pass. This will make EarlyCSE miss some opportunities.

Also only recognizing some abs pattern will make equal instructions have different hash value. For example, see https://bugs.llvm.org/show_bug.cgi?id=48058

    %neg = sub i8 0, %a
    %cmp1 = icmp slt i8 %a, 0
    %cmp2 = icmp sge i8 %a, 0 
    %m1 = select i1 %cmp1, i8 %a, i8 %neg
    %m2 = select i1 %cmp2, i8 %neg, i8 %a
    %r = xor i8 %m2, %m1
    ret i8 %r
  `

`%m1` and `%m2` are recognized as same instructions in `isEqualImpl` because of inverse predicate and same operands for these two `select`.

But in `getHashValueImpl`, `%m1` is recognized as NABS because it is already in canonicalize form of abs. But `%m2` is not in canonicalize form of abs, so it is not recognized as NABS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90734

Files:
  llvm/lib/Transforms/Scalar/EarlyCSE.cpp
  llvm/test/Transforms/EarlyCSE/commute.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90734.302737.patch
Type: text/x-patch
Size: 6384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201104/a77f20c1/attachment.bin>


More information about the llvm-commits mailing list