[llvm-dev] undef * 0

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 12 22:39:56 PDT 2016

Sanjoy Das wrote:
 > Here is a simpler example of a similar issue: `X - X` is not
 > equivalent `0`, in that `0` cannot be replaced with `X - X`, even
 > though `X - X` can be folded to `0`.

I forgot to state that `X` above is some unknown value which can
potentially be `undef`.  A full example would be:

define i32 @f_0(i32 %x) {
   ret i32 0

define i32 @f_1(i32 %x) {
   %v = sub i32 %x, %x
   ret i32 %v

`@f_1` can be optimized to `@f_0` but not vice versa, unless you
somehow know that `%x` cannot be `undef`.

-- Sanjoy

More information about the llvm-dev mailing list