[all-commits] [llvm/llvm-project] c66169: [InstCombine] fold icmp with 'mul nsw/nuw' and con...

RotateRight via All-commits all-commits at lists.llvm.org
Wed Aug 5 14:30:52 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: c66169136fe667d653ff40ba4bd9f6047702e93c
      https://github.com/llvm/llvm-project/commit/c66169136fe667d653ff40ba4bd9f6047702e93c
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2020-08-05 (Wed, 05 Aug 2020)

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

  Log Message:
  -----------
  [InstCombine] fold icmp with 'mul nsw/nuw' and constant operands

This also removes a more specific fold that only handled icmp with 0.

https://rise4fun.com/Alive/sdM9

  Name: mul nsw with icmp eq
  Pre: (C1 != 0) && (C2 % C1) == 0
  %a = mul nsw i8 %x, C1
  %r = icmp eq i8 %a, C2
    =>
  %r = icmp eq i8 %x, C2 / C1

  Name: mul nuw with icmp eq
  Pre: (C1 != 0) && (C2 %u C1) == 0
  %a = mul nuw i8 %x, C1
  %r = icmp eq i8 %a, C2
    =>
  %r = icmp eq i8 %x, C2 /u C1

  Name: mul nsw with icmp ne
  Pre: (C1 != 0) && (C2 % C1) == 0
  %a = mul nsw i8 %x, C1
  %r = icmp ne i8 %a, C2
    =>
  %r = icmp ne i8 %x, C2 / C1

  Name: mul nuw with icmp ne
  Pre: (C1 != 0) && (C2 %u C1) == 0
  %a = mul nuw i8 %x, C1
  %r = icmp ne i8 %a, C2
    =>
  %r = icmp ne i8 %x, C2 /u C1




More information about the All-commits mailing list