[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 23 12:00:15 PDT 2021


aqjune created this revision.
aqjune added reviewers: spatel, nikic, lebedev.ri.
Herald added subscribers: wenlei, kerbowa, pengfei, hiraditya, nhaehnle, jvesely.
aqjune requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This is a patch that disables the poison-unsafe select -> and/or i1 folding.

It has been blocking D72396 <https://reviews.llvm.org/D72396> and also has been the source of a few miscompilations
described in llvm.org/pr49688 .
D99674 <https://reviews.llvm.org/D99674> conditionally blocked this folding and successfully fixed the latter one.
The former one was still blocked, and this patch addresses it.

Note that many test functions that has `_logical` suffix are now deoptimized.
These are created by @nikic to check the impact of disabling this optimization
by copying existing original functions and replacing and/or with select.

I can see that most of these are poison-unsafe; they can be revived by introducing
freeze instruction. I left comments at fcmp + select optimizations (or-fcmp.ll, and-fcmp.ll)
because I think they are good targets for freeze fix.

Two tests have deoptimizations which seem important to me:

llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll
Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll

The first one needs to teach vectorization, IIUC.
The second one is slightly complex; we need noundef at arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101191

Files:
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/2008-02-28-OrFCmpCrash.ll
  llvm/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
  llvm/test/Transforms/InstCombine/and-fcmp.ll
  llvm/test/Transforms/InstCombine/and-or-icmp-min-max.ll
  llvm/test/Transforms/InstCombine/and-or-icmp-nullptr.ll
  llvm/test/Transforms/InstCombine/and-or-icmps.ll
  llvm/test/Transforms/InstCombine/and.ll
  llvm/test/Transforms/InstCombine/and2.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/InstCombine/bit-checks.ll
  llvm/test/Transforms/InstCombine/demorgan.ll
  llvm/test/Transforms/InstCombine/dont-distribute-phi.ll
  llvm/test/Transforms/InstCombine/icmp.ll
  llvm/test/Transforms/InstCombine/ispow2.ll
  llvm/test/Transforms/InstCombine/logical-select-inseltpoison.ll
  llvm/test/Transforms/InstCombine/logical-select.ll
  llvm/test/Transforms/InstCombine/onehot_merge.ll
  llvm/test/Transforms/InstCombine/or-fcmp.ll
  llvm/test/Transforms/InstCombine/or.ll
  llvm/test/Transforms/InstCombine/prevent-cmp-merge.ll
  llvm/test/Transforms/InstCombine/range-check.ll
  llvm/test/Transforms/InstCombine/select-and-or.ll
  llvm/test/Transforms/InstCombine/select-bitext.ll
  llvm/test/Transforms/InstCombine/select-cmp-br.ll
  llvm/test/Transforms/InstCombine/select-safe-bool-transforms.ll
  llvm/test/Transforms/InstCombine/select-safe-transforms.ll
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstCombine/sign-test-and-or.ll
  llvm/test/Transforms/InstCombine/signed-truncation-check.ll
  llvm/test/Transforms/InstCombine/umul-sign-check.ll
  llvm/test/Transforms/InstCombine/usub-overflow-known-by-implied-cond.ll
  llvm/test/Transforms/InstCombine/widenable-conditions.ll
  llvm/test/Transforms/InstCombine/zext-or-icmp.ll
  llvm/test/Transforms/LoopSimplify/merge-exits.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
  llvm/test/Transforms/LoopVectorize/reduction-inloop-pred.ll
  llvm/test/Transforms/LoopVectorize/reduction-inloop.ll
  llvm/test/Transforms/PGOProfile/chr.ll
  llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll
  llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101191.340131.patch
Type: text/x-patch
Size: 182731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210423/5e2501ae/attachment-0001.bin>


More information about the llvm-commits mailing list