[llvm] r344559 - [InstCombine] add tests for bitwise logic --> select; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 15 14:43:53 PDT 2018
Author: spatel
Date: Mon Oct 15 14:43:53 2018
New Revision: 344559
URL: http://llvm.org/viewvc/llvm-project?rev=344559&view=rev
Log:
[InstCombine] add tests for bitwise logic --> select; NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/logical-select.ll
llvm/trunk/test/Transforms/InstCombine/vec_sext.ll
Modified: llvm/trunk/test/Transforms/InstCombine/logical-select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/logical-select.ll?rev=344559&r1=344558&r2=344559&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/logical-select.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/logical-select.ll Mon Oct 15 14:43:53 2018
@@ -531,3 +531,39 @@ define <4 x i32> @vec_sel_xor_multi_use(
ret <4 x i32> %add
}
+; The 'ashr' guarantees that we have a bitmask, so this is select with truncated condition.
+
+define i32 @allSignBits(i32 %cond, i32 %tval, i32 %fval) {
+; CHECK-LABEL: @allSignBits(
+; CHECK-NEXT: [[BITMASK:%.*]] = ashr i32 [[COND:%.*]], 31
+; CHECK-NEXT: [[NOT_BITMASK:%.*]] = xor i32 [[BITMASK]], -1
+; CHECK-NEXT: [[A1:%.*]] = and i32 [[BITMASK]], [[TVAL:%.*]]
+; CHECK-NEXT: [[A2:%.*]] = and i32 [[NOT_BITMASK]], [[FVAL:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = or i32 [[A1]], [[A2]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %bitmask = ashr i32 %cond, 31
+ %not_bitmask = xor i32 %bitmask, -1
+ %a1 = and i32 %tval, %bitmask
+ %a2 = and i32 %not_bitmask, %fval
+ %sel = or i32 %a1, %a2
+ ret i32 %sel
+}
+
+define <4 x i8> @allSignBits_vec(<4 x i8> %cond, <4 x i8> %tval, <4 x i8> %fval) {
+; CHECK-LABEL: @allSignBits_vec(
+; CHECK-NEXT: [[BITMASK:%.*]] = ashr <4 x i8> [[COND:%.*]], <i8 7, i8 7, i8 7, i8 7>
+; CHECK-NEXT: [[NOT_BITMASK:%.*]] = xor <4 x i8> [[BITMASK]], <i8 -1, i8 -1, i8 -1, i8 -1>
+; CHECK-NEXT: [[A1:%.*]] = and <4 x i8> [[BITMASK]], [[TVAL:%.*]]
+; CHECK-NEXT: [[A2:%.*]] = and <4 x i8> [[NOT_BITMASK]], [[FVAL:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = or <4 x i8> [[A2]], [[A1]]
+; CHECK-NEXT: ret <4 x i8> [[SEL]]
+;
+ %bitmask = ashr <4 x i8> %cond, <i8 7, i8 7, i8 7, i8 7>
+ %not_bitmask = xor <4 x i8> %bitmask, <i8 -1, i8 -1, i8 -1, i8 -1>
+ %a1 = and <4 x i8> %tval, %bitmask
+ %a2 = and <4 x i8> %fval, %not_bitmask
+ %sel = or <4 x i8> %a2, %a1
+ ret <4 x i8> %sel
+}
+
Modified: llvm/trunk/test/Transforms/InstCombine/vec_sext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_sext.ll?rev=344559&r1=344558&r2=344559&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vec_sext.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vec_sext.ll Mon Oct 15 14:43:53 2018
@@ -1,8 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
-define <4 x i32> @psignd_3(<4 x i32> %a, <4 x i32> %b) {
-; CHECK-LABEL: @psignd_3(
+define <4 x i32> @vec_select(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: @vec_select(
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <4 x i32> zeroinitializer, [[A:%.*]]
; CHECK-NEXT: [[B_LOBIT1:%.*]] = ashr <4 x i32> [[B:%.*]], <i32 31, i32 31, i32 31, i32 31>
; CHECK-NEXT: [[T1:%.*]] = xor <4 x i32> [[B_LOBIT1]], <i32 -1, i32 -1, i32 -1, i32 -1>
@@ -23,8 +23,8 @@ define <4 x i32> @psignd_3(<4 x i32> %a,
ret <4 x i32> %cond
}
-define <4 x i32> @test1(<4 x i32> %a, <4 x i32> %b) {
-; CHECK-LABEL: @test1(
+define <4 x i32> @vec_select_alternate_sign_bit_test(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: @vec_select_alternate_sign_bit_test(
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <4 x i32> zeroinitializer, [[A:%.*]]
; CHECK-NEXT: [[B_LOBIT1:%.*]] = ashr <4 x i32> [[B:%.*]], <i32 31, i32 31, i32 31, i32 31>
; CHECK-NEXT: [[B_LOBIT1_NOT:%.*]] = xor <4 x i32> [[B_LOBIT1]], <i32 -1, i32 -1, i32 -1, i32 -1>
More information about the llvm-commits
mailing list