From: Sanjay Patel Date: Fri, 30 Sep 2016 18:10:14 +0000 (+0000) Subject: [InstCombine] add tests for select X, (ext X), C X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=976632d9a27ecbc602ff1064b2adbe21d9253254;p=llvm [InstCombine] add tests for select X, (ext X), C git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282891 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/select-bitext.ll b/test/Transforms/InstCombine/select-bitext.ll index fc379d28a73..34e260a286d 100644 --- a/test/Transforms/InstCombine/select-bitext.ll +++ b/test/Transforms/InstCombine/select-bitext.ll @@ -198,3 +198,94 @@ define <2 x i32> @scalar_select_of_vectors_zext(<2 x i1> %cca, i1 %ccb) { %r = select i1 %ccb, <2 x i32> %ccax, <2 x i32> ret <2 x i32> %r } + +define i32 @sext_true_val_must_be_all_ones(i1 %x) { +; CHECK-LABEL: @sext_true_val_must_be_all_ones( +; CHECK-NEXT: [[EXT:%.*]] = sext i1 %x to i32 +; CHECK-NEXT: [[SEL:%.*]] = select i1 %x, i32 [[EXT]], i32 42, !prof !0 +; CHECK-NEXT: ret i32 [[SEL]] +; + %ext = sext i1 %x to i32 + %sel = select i1 %x, i32 %ext, i32 42, !prof !0 + ret i32 %sel +} + +define <2 x i32> @sext_true_val_must_be_all_ones_vec(<2 x i1> %x) { +; CHECK-LABEL: @sext_true_val_must_be_all_ones_vec( +; CHECK-NEXT: [[EXT:%.*]] = sext <2 x i1> %x to <2 x i32> +; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> %x, <2 x i32> [[EXT]], <2 x i32> , !prof !0 +; CHECK-NEXT: ret <2 x i32> [[SEL]] +; + %ext = sext <2 x i1> %x to <2 x i32> + %sel = select <2 x i1> %x, <2 x i32> %ext, <2 x i32> , !prof !0 + ret <2 x i32> %sel +} + +define i32 @zext_true_val_must_be_one(i1 %x) { +; CHECK-LABEL: @zext_true_val_must_be_one( +; CHECK-NEXT: [[EXT:%.*]] = zext i1 %x to i32 +; CHECK-NEXT: [[SEL:%.*]] = select i1 %x, i32 [[EXT]], i32 42, !prof !0 +; CHECK-NEXT: ret i32 [[SEL]] +; + %ext = zext i1 %x to i32 + %sel = select i1 %x, i32 %ext, i32 42, !prof !0 + ret i32 %sel +} + +define <2 x i32> @zext_true_val_must_be_one_vec(<2 x i1> %x) { +; CHECK-LABEL: @zext_true_val_must_be_one_vec( +; CHECK-NEXT: [[EXT:%.*]] = zext <2 x i1> %x to <2 x i32> +; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> %x, <2 x i32> [[EXT]], <2 x i32> , !prof !0 +; CHECK-NEXT: ret <2 x i32> [[SEL]] +; + %ext = zext <2 x i1> %x to <2 x i32> + %sel = select <2 x i1> %x, <2 x i32> %ext, <2 x i32> , !prof !0 + ret <2 x i32> %sel +} + +define i32 @sext_false_val_must_be_zero(i1 %x) { +; CHECK-LABEL: @sext_false_val_must_be_zero( +; CHECK-NEXT: [[EXT:%.*]] = sext i1 %x to i32 +; CHECK-NEXT: [[SEL:%.*]] = select i1 %x, i32 42, i32 [[EXT]], !prof !0 +; CHECK-NEXT: ret i32 [[SEL]] +; + %ext = sext i1 %x to i32 + %sel = select i1 %x, i32 42, i32 %ext, !prof !0 + ret i32 %sel +} + +define <2 x i32> @sext_false_val_must_be_zero_vec(<2 x i1> %x) { +; CHECK-LABEL: @sext_false_val_must_be_zero_vec( +; CHECK-NEXT: [[EXT:%.*]] = sext <2 x i1> %x to <2 x i32> +; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> %x, <2 x i32> , <2 x i32> [[EXT]], !prof !0 +; CHECK-NEXT: ret <2 x i32> [[SEL]] +; + %ext = sext <2 x i1> %x to <2 x i32> + %sel = select <2 x i1> %x, <2 x i32> , <2 x i32> %ext, !prof !0 + ret <2 x i32> %sel +} + +define i32 @zext_false_val_must_be_zero(i1 %x) { +; CHECK-LABEL: @zext_false_val_must_be_zero( +; CHECK-NEXT: [[EXT:%.*]] = zext i1 %x to i32 +; CHECK-NEXT: [[SEL:%.*]] = select i1 %x, i32 42, i32 [[EXT]], !prof !0 +; CHECK-NEXT: ret i32 [[SEL]] +; + %ext = zext i1 %x to i32 + %sel = select i1 %x, i32 42, i32 %ext, !prof !0 + ret i32 %sel +} + +define <2 x i32> @zext_false_val_must_be_zero_vec(<2 x i1> %x) { +; CHECK-LABEL: @zext_false_val_must_be_zero_vec( +; CHECK-NEXT: [[EXT:%.*]] = zext <2 x i1> %x to <2 x i32> +; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> %x, <2 x i32> , <2 x i32> [[EXT]], !prof !0 +; CHECK-NEXT: ret <2 x i32> [[SEL]] +; + %ext = zext <2 x i1> %x to <2 x i32> + %sel = select <2 x i1> %x, <2 x i32> , <2 x i32> %ext, !prof !0 + ret <2 x i32> %sel +} + +!0 = !{!"branch_weights", i32 3, i32 5} +