Merging r260703:
[oota-llvm.git] / test / Transforms / InstCombine / zext-bool-add-sub.ll
index c1b9d1437434dbfdb40b57907e8709ecad4451ed..6fa4d70d6360d7f5234ed21e81131d68d5eeb65b 100644 (file)
@@ -1,29 +1,16 @@
-; RUN: opt %s -instcombine | llvm-dis | not grep zext
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; rdar://11748024
 
-define i32 @a(i1 %x) {
+define i32 @a(i1 zeroext %x, i1 zeroext %y) {
 entry:
-        %y = zext i1 %x to i32
-        %res = add i32 %y, 1
-        ret i32 %res
-}
-
-define i32 @b(i1 %x) {
-entry:
-        %y = zext i1 %x to i32
-        %res = add i32 %y, -1
-        ret i32 %res
-}
-
-define i32 @c(i1 %x) {
-entry:
-        %y = zext i1 %x to i32
-        %res = sub i32 0, %y
-        ret i32 %res
-}
-
-define i32 @d(i1 %x) {
-entry:
-        %y = zext i1 %x to i32
-        %res = sub i32 3, %y
-        ret i32 %res
+; CHECK-LABEL: @a(
+; CHECK: [[TMP1:%.*]] = sext i1 %y to i32
+; CHECK: [[TMP2:%.*]] = select i1 %x, i32 2, i32 1
+; CHECK-NEXT: add nsw i32 [[TMP2]], [[TMP1]]
+  %conv = zext i1 %x to i32
+  %conv3 = zext i1 %y to i32
+  %conv3.neg = sub i32 0, %conv3
+  %sub = add i32 %conv, 1
+  %add = add i32 %sub, %conv3.neg
+  ret i32 %add
 }