Duncan Sands | adc7771f | 2010-11-23 14:23:47 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -instcombine -S | FileCheck %s |
| 2 | define 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 Sands | adc7771f | 2010-11-23 14:23:47 +0000 | [diff] [blame] | 8 | ret i32 %res |
Duncan Sands | fbb9ac3 | 2010-12-22 13:36:08 +0000 | [diff] [blame] | 9 | ; CHECK-NEXT: mul i32 %x, %y |
| 10 | ; CHECK-NEXT: ret i32 |
| 11 | } |
| 12 | |
| 13 | define 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 Sands | adc7771f | 2010-11-23 14:23:47 +0000 | [diff] [blame] | 23 | } |