blob: 4f8e8dc713b4779193b0146943a8bca2becf3e56 [file] [log] [blame]
Duncan Sandsadc7771f2010-11-23 14:23:47 +00001; RUN: opt < %s -instcombine -S | FileCheck %s
2define i32 @foo(i32 %x, i32 %y) {
3; CHECK: @foo
4 %add = add nsw i32 %y, %x
5 %mul = mul nsw i32 %add, %y
6 %square = mul nsw i32 %y, %y
7 %res = sub i32 %mul, %square
Duncan Sandsadc7771f2010-11-23 14:23:47 +00008 ret i32 %res
Duncan Sandsfbb9ac32010-12-22 13:36:08 +00009; CHECK-NEXT: mul i32 %x, %y
10; CHECK-NEXT: ret i32
11}
12
13define i1 @bar(i64 %x, i64 %y) {
14; CHECK: @bar
15 %a = and i64 %y, %x
16; CHECK: and
17; CHECK-NOT: and
18 %not = xor i64 %a, -1
19 %b = and i64 %y, %not
20 %r = icmp eq i64 %b, 0
21 ret i1 %r
22; CHECK: ret i1
Duncan Sandsadc7771f2010-11-23 14:23:47 +000023}