[all-commits] [llvm/llvm-project] 2d61b5: Reduce code duplication in simplifySelectWithICmpC...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Sep 15 01:44:13 PDT 2020


  Branch: refs/heads/release/11.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 2d61b5ea8079fb28db6a7b25cfc844fa6c21f8c4
      https://github.com/llvm/llvm-project/commit/2d61b5ea8079fb28db6a7b25cfc844fa6c21f8c4
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-09-15 (Tue, 15 Sep 2020)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp

  Log Message:
  -----------
  Reduce code duplication in simplifySelectWithICmpCond (NFC)

Canonicalize icmp ne to icmp eq and implement all the folds only once.


  Commit: d720e5855dcf57b5b88ee6a4147ccd762115278a
      https://github.com/llvm/llvm-project/commit/d720e5855dcf57b5b88ee6a4147ccd762115278a
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-09-15 (Tue, 15 Sep 2020)

  Changed paths:
    M llvm/test/Transforms/InstCombine/select.ll

  Log Message:
  -----------
  Add test for PR47322 (NFC)


  Commit: be318969e245db0cd5471bff2a7cbfa3fad2b075
      https://github.com/llvm/llvm-project/commit/be318969e245db0cd5471bff2a7cbfa3fad2b075
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-09-15 (Tue, 15 Sep 2020)

  Changed paths:
    M llvm/include/llvm/Analysis/InstructionSimplify.h
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
    M llvm/test/Transforms/InstCombine/select.ll

  Log Message:
  -----------
  Fix incorrect SimplifyWithOpReplaced transform (PR47322)

This is a followup to D86834, which partially fixed this issue in
InstSimplify. However, InstCombine repeats the same transform while
dropping poison flags -- which does not cover cases where poison is
introduced in some other way.

The fix here is a bit more comprehensive, because things are quite
entangled, and it's hard to only partially address it without
regressing optimization. There are really two changes here:

 * Export the SimplifyWithOpReplaced API from InstSimplify, with an
   added AllowRefinement flag. For replacements inside the TrueVal
   we don't actually care whether refinement occurs or not, the
   replacement is always legal. This part of the transform is now
   done in InstSimplify only. (It should be noted that the current
   AllowRefinement check is not sufficient -- that's an issue we
   need to address separately.)
 * Change the InstCombine fold to work by temporarily dropping
   poison generating flags, running the fold and then restoring the
   flags if it didn't work out. This will ensure that the InstCombine
   fold is correct as long as the InstSimplify fold is correct.

Differential Revision: https://reviews.llvm.org/D87445


Compare: https://github.com/llvm/llvm-project/compare/b3fb40b3a3c1...be318969e245


More information about the All-commits mailing list