blob: 20bfed87798b69f6b396647d42ba0da34eb8409d [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) {
Stephen Linc1c7a132013-07-14 01:42:54 +00003; CHECK-LABEL: @foo(
Duncan Sandsadc7771f2010-11-23 14:23:47 +00004 %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) {
Stephen Linc1c7a132013-07-14 01:42:54 +000014; CHECK-LABEL: @bar(
Duncan Sandsfbb9ac32010-12-22 13:36:08 +000015 %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}