[all-commits] [llvm/llvm-project] ea6171: [InstCombine] add tests for icmp with udiv operand...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Thu May 26 06:10:23 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ea6171c108c47c1ee486388adfa106e13e280e33
      https://github.com/llvm/llvm-project/commit/ea6171c108c47c1ee486388adfa106e13e280e33
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-05-26 (Thu, 26 May 2022)

  Changed paths:
    M llvm/test/Transforms/InstCombine/icmp-div-constant.ll

  Log Message:
  -----------
  [InstCombine] add tests for icmp with udiv operand; NFC

This covers a generalization of one of the transforms
suggested in #55695.


  Commit: 3952c905ef08580de1ddc5d776177497407a6093
      https://github.com/llvm/llvm-project/commit/3952c905ef08580de1ddc5d776177497407a6093
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-05-26 (Thu, 26 May 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/icmp-div-constant.ll

  Log Message:
  -----------
  [InstCombine] fold icmp equality with udiv and large constant

With large compare constant:
(X u/ Y) == C --> (X == C) && (Y == 1)
(X u/ Y) != C --> (X != C) || (Y != 1)

https://alive2.llvm.org/ce/z/EhKwh6

There are various potential missing icmp (div) transforms shown here:
https://github.com/llvm/llvm-project/issues/55695

This is a generalization for part of the udiv + equality.
I didn't check in detail, but some of those may only make sense as
codegen transforms.

This results in one extra instruction in IR, but it is better for
analysis, and looks much better in codegen on all targets that I tried.

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


Compare: https://github.com/llvm/llvm-project/compare/851bfc07c86e...3952c905ef08


More information about the All-commits mailing list