[all-commits] [llvm/llvm-project] 452279: [InstCombine] prevent miscompiles from select-of-d...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Wed Mar 1 05:56:05 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 452279efe21a61c7e17189da99347f7755f27cb0
      https://github.com/llvm/llvm-project/commit/452279efe21a61c7e17189da99347f7755f27cb0
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2023-03-01 (Wed, 01 Mar 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
    M llvm/test/Transforms/InstCombine/select-divrem.ll

  Log Message:
  -----------
  [InstCombine] prevent miscompiles from select-of-div/rem transform

This avoids the danger shown in issue #60906.
There were no regression tests for these patterns, so these potential
failures have been around for a long time.

We freeze the condition and preserve the optimization because
getting rid of a div/rem is always a win.

Here are a couple of examples that can be corrected by freezing the
condition:
https://alive2.llvm.org/ce/z/sXHTTC

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




More information about the All-commits mailing list