[PATCH] Added InstCombine transform for pattern "(A ^ B) & ((~A) ^ B) -> False"

David Majnemer david.majnemer at gmail.com
Thu Aug 7 23:04:51 PDT 2014


I don't think we need to do anything here, running the reassociate pass before instcombine makes this problem go away.

  $ cat t.ll
  define i32 @test15(i32 %x, i32 %y) {
   %nega = xor i32 %x, -1
   %xor = xor i32 %nega, %y
   %xor1 = xor i32 %x, %y
   %and = and i32 %xor, %xor1
   ret i32 %and
  }

  define i32 @test16(i32 %x, i32 %y) {
   %xor = xor i32 %x, %y
   %nega = xor i32 %x, -1
   %xor1 = xor i32 %nega, %y
   %and = and i32 %xor, %xor1
   ret i32 %and
  }

  $ ~/llvm/Debug+Asserts/bin/opt -reassociate -instcombine t.ll -o - -S
  ; ModuleID = 't.ll'

  define i32 @test15(i32 %x, i32 %y) {
    ret i32 0
  }

  define i32 @test16(i32 %x, i32 %y) {
    ret i32 0
  }

http://reviews.llvm.org/D4690






More information about the llvm-commits mailing list