[all-commits] [llvm/llvm-project] 36e2e2: [InstCombine] Fix incorrect SimplifyWithOpReplaced...

Nikita Popov via All-commits all-commits at lists.llvm.org
Sat Sep 12 05:45:30 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 36e2e2e12efb6b02ad07f502d61b9a95937edb08
      https://github.com/llvm/llvm-project/commit/36e2e2e12efb6b02ad07f502d61b9a95937edb08
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2020-09-12 (Sat, 12 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:
  -----------
  [InstCombine] 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




More information about the All-commits mailing list