[PATCH] D69519: [InstCombine] make icmp vector canonicalization safe for constant with undef elements

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 10:26:11 PDT 2019


spatel created this revision.
spatel added reviewers: lebedev.ri, nlopes, RKSimon.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

This is a fix for:
https://bugs.llvm.org/show_bug.cgi?id=43730
...and as shown there, we have an existing test case that shows a potential miscompile.

We could just bail out for vector constants that contain any undef elements, or we can do as shown here:
allow the transform, but replace the undefs with a safe value.

For the tests shown, this results in a full splat constant (no undefs) which is probably a win for further IR analysis because we conservatively don't match undefs in most cases. Codegen can probably recover these kinds of undef lanes via demanded elements analysis if that's profitable.


https://reviews.llvm.org/D69519

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-eq-to-icmp-ule.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sge-to-icmp-sle.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sle-to-icmp-sle.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-uge-to-icmp-ule.ll
  llvm/test/Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-ule-to-icmp-ule.ll
  llvm/test/Transforms/InstCombine/icmp-vec.ll
  llvm/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69519.226696.patch
Type: text/x-patch
Size: 6994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191028/d5609e1c/attachment.bin>


More information about the llvm-commits mailing list