blob: 0277d39b1fca2dda6bc8e9e49604264d8aa882db [file] [log] [blame]
Duncan Sandsba286d72011-10-26 20:55:21 +00001; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3define i64 @pow2(i32 %x) {
Stephen Linc1c7a132013-07-14 01:42:54 +00004; CHECK-LABEL: @pow2(
Duncan Sandsba286d72011-10-26 20:55:21 +00005 %negx = sub i32 0, %x
6 %x2 = and i32 %x, %negx
7 %e = zext i32 %x2 to i64
8 %nege = sub i64 0, %e
9 %e2 = and i64 %e, %nege
10 ret i64 %e2
11; CHECK: ret i64 %e
12}
Duncan Sands985ba632011-10-28 18:30:05 +000013
14define i64 @pow2b(i32 %x) {
Stephen Linc1c7a132013-07-14 01:42:54 +000015; CHECK-LABEL: @pow2b(
Duncan Sands985ba632011-10-28 18:30:05 +000016 %sh = shl i32 2, %x
17 %e = zext i32 %sh to i64
18 %nege = sub i64 0, %e
19 %e2 = and i64 %e, %nege
20 ret i64 %e2
21; CHECK: ret i64 %e
22}
David Majnemercd4fbcd2014-07-31 04:49:18 +000023
24define i32 @sub_neg_nuw(i32 %x, i32 %y) {
25; CHECK-LABEL: @sub_neg_nuw(
26 %neg = sub nuw i32 0, %y
27 %sub = sub i32 %x, %neg
28 ret i32 %sub
29; CHECK: ret i32 %x
30}