[all-commits] [llvm/llvm-project] 36bd25: [InstCombine][test] add tests for icmp with consta...

RotateRight via All-commits all-commits at lists.llvm.org
Wed Jun 30 10:45:29 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 36bd25db3dd5b76f3ab31fc95bd04f18a8af6347
      https://github.com/llvm/llvm-project/commit/36bd25db3dd5b76f3ab31fc95bd04f18a8af6347
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-06-30 (Wed, 30 Jun 2021)

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

  Log Message:
  -----------
  [InstCombine][test] add tests for icmp with constant and offset; NFC


  Commit: c7b658aeb526c3e68b0cea89f0746f45b5366827
      https://github.com/llvm/llvm-project/commit/c7b658aeb526c3e68b0cea89f0746f45b5366827
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-06-30 (Wed, 30 Jun 2021)

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

  Log Message:
  -----------
  [InstCombine] fold icmp of offset value with constant

There must be a better way to describe this pattern in words?
(X + C2) >u C --> X <s -C2 (if C == C2 + SMAX)

This could be extended to handle the more general (non-constant)
pattern too:
https://alive2.llvm.org/ce/z/rdfNFP

  define i1 @src(i8 %a, i8 %c1) {
    %t = add i8 %a, %c1
    %c2 = add i8 %c1, 127 ; SMAX
    %ov = icmp ugt i8 %t, %c2
    ret i1 %ov
  }

  define i1 @tgt(i8 %a, i8 %c1) {
    %neg_c1 = sub i8 0, %c1
    %ov = icmp slt i8 %a, %neg_c1
    ret i1 %ov
  }

The pattern was noticed as a by-product of D104932.


Compare: https://github.com/llvm/llvm-project/compare/230df8a419f2...c7b658aeb526


More information about the All-commits mailing list