aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-04-05 13:33:10 +0000
committerSanjay Patel <spatel@rotateright.com>2017-04-05 13:33:10 +0000
commit8090e6f00450afce056760371d3cc46a4176fcfb (patch)
tree40b8f9c677698b9b411e75be1a230d4bacde478a
parent4f3eb249cf93ca50704ebdab04b0d95307abcbba (diff)
downloadllvm-8090e6f00450afce056760371d3cc46a4176fcfb.zip
llvm-8090e6f00450afce056760371d3cc46a4176fcfb.tar.gz
llvm-8090e6f00450afce056760371d3cc46a4176fcfb.tar.bz2
[InstCombine] add tests for missing add canonicalization; NFC
llvm-svn: 299539
-rw-r--r--llvm/test/Transforms/InstCombine/add.ll26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll
index 94e1837..84a48ec 100644
--- a/llvm/test/Transforms/InstCombine/add.ll
+++ b/llvm/test/Transforms/InstCombine/add.ll
@@ -1,6 +1,32 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
+; TODO: This should be canonicalized to either a select or xor+zext.
+
+define i32 @select_0_or_1_from_bool(i1 %x) {
+; CHECK-LABEL: @select_0_or_1_from_bool(
+; CHECK-NEXT: [[EXT:%.*]] = sext i1 %x to i32
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[EXT]], 1
+; CHECK-NEXT: ret i32 [[ADD]]
+;
+ %ext = sext i1 %x to i32
+ %add = add i32 %ext, 1
+ ret i32 %add
+}
+
+; TODO: This should be canonicalized to either a select or xor+zext.
+
+define <2 x i32> @select_0_or_1_from_bool_vec(<2 x i1> %x) {
+; CHECK-LABEL: @select_0_or_1_from_bool_vec(
+; CHECK-NEXT: [[EXT:%.*]] = sext <2 x i1> %x to <2 x i32>
+; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i32> [[EXT]], <i32 1, i32 1>
+; CHECK-NEXT: ret <2 x i32> [[ADD]]
+;
+ %ext = sext <2 x i1> %x to <2 x i32>
+ %add = add <2 x i32> %ext, <i32 1, i32 1>
+ ret <2 x i32> %add
+}
+
define i32 @test1(i32 %A) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: ret i32 %A