[all-commits] [llvm/llvm-project] 6eae6b: [InstCombine] allow more folds for multi-use selec...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Sun Nov 13 07:31:15 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6eae6b3722d9204fa93b772e24afab93406cc143
      https://github.com/llvm/llvm-project/commit/6eae6b3722d9204fa93b772e24afab93406cc143
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-11-13 (Sun, 13 Nov 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/InstCombine/binop-select.ll

  Log Message:
  -----------
  [InstCombine] allow more folds for multi-use selects (2nd try)

The 1st try ( 681a6a399022 ) was reverted because it caused
a DataFlowSanitizer bot failure.

This try modifies the existing calls to simplifyBinOp() to
not use a query that sets the context instruction because
that seems like a likely source of failure. Since we already
try those simplifies with multi-use patterns in some cases,
that means the bug is likely present even without this patch.

However, I have not been able to reduce a test to prove that
this was the bug, so if we see any bot failures with this patch,
then it should be reverted again.

The reduced simplify power does not affect any optimizations
in existing, motivating regression tests.

Original commit message:

The 'and' case showed up in a recent bug report and prevented
more follow-on transforms from happening.

We could handle more patterns (for example, the select arms
simplified, but not to constant values), but this seems
like a safe, conservative enhancement. The backend can
convert select-of-constants to math/logic in many cases
if it is profitable.

There is a lot of overlapping logic for these kinds of patterns
(see SimplifySelectsFeedingBinaryOp() and FoldOpIntoSelect()),
so there may be some opportunity to improve efficiency.

There are also optimization gaps/inconsistency because we do
not call this code for all bin-opcodes (see TODO for ashr test).




More information about the All-commits mailing list