[all-commits] [llvm/llvm-project] a7ed21: [InstCombine] try to fold div with constant divide...

RotateRight via All-commits all-commits at lists.llvm.org
Wed Dec 8 07:31:12 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a7ed21aa1e1d73e8c51490a52d6ebe6975fc558b
      https://github.com/llvm/llvm-project/commit/a7ed21aa1e1d73e8c51490a52d6ebe6975fc558b
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-12-08 (Wed, 08 Dec 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/div.ll

  Log Message:
  -----------
  [InstCombine] try to fold div with constant dividend and select-of-constants divisor

We avoid this fold in the more general cases where we use FoldOpIntoSelect.
That's because -- unlike most binary opcodes -- 'div' can't usually be
speculated with a variable divisor since it can have immediate UB. But in
the case where both arms of the select are constants, we can safely evaluate
both sides and eliminate 'div' completely.

This is a follow-up to the equivalent fold for 'rem' opcodes:
D115173 / f65be726ab50




More information about the All-commits mailing list