[PATCH] D58633: [InstCombine] remove one-use restriction for icmp+add constant fold

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 25 09:36:22 PST 2019


spatel created this revision.
spatel added reviewers: efriedma, lebedev.ri, RKSimon, nikic.
Herald added subscribers: jdoerfert, zzheng, hiraditya, mcrosier.
Herald added a project: LLVM.

Remove the use of an add with constant when compared to another constant:
(A + C2) == C --> A == (C - C2)
(A + C2) != C --> A != (C - C2)

I noticed an inconsistency in the canonicalization of this pattern as part of D57516 <https://reviews.llvm.org/D57516> and rL354746 <https://reviews.llvm.org/rL354746>, so that is shown in the uaddo.ll test file.

I checked asm for some of the tests where the induction variable test is changing, and I don't see any diffs in the final results, so I'm assuming that something later (LSR?) converts that to optimized form either way?


https://reviews.llvm.org/D58633

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/gep-combine-loop-invariant.ll
  llvm/test/Transforms/InstCombine/narrow.ll
  llvm/test/Transforms/InstCombine/uaddo.ll
  llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
  llvm/test/Transforms/LoopUnroll/runtime-unroll-remainder.ll
  llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll
  llvm/test/Transforms/LoopVectorize/X86/masked_load_store.ll
  llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll
  llvm/test/Transforms/LoopVectorize/X86/small-size.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
  llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58633.188201.patch
Type: text/x-patch
Size: 49681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190225/303d80e3/attachment-0001.bin>


More information about the llvm-commits mailing list