[llvm] r336065 - [InstCombine] add abs tests with undef elts; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 1 10:14:38 PDT 2018
Author: spatel
Date: Sun Jul 1 10:14:37 2018
New Revision: 336065
URL: http://llvm.org/viewvc/llvm-project?rev=336065&view=rev
Log:
[InstCombine] add abs tests with undef elts; NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/abs-1.ll
Modified: llvm/trunk/test/Transforms/InstCombine/abs-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/abs-1.ll?rev=336065&r1=336064&r2=336065&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/abs-1.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/abs-1.ll Sun Jul 1 10:14:37 2018
@@ -73,6 +73,21 @@ define <2 x i8> @abs_canonical_2(<2 x i8
ret <2 x i8> %abs
}
+; Even if a constant has undef elements.
+
+define <2 x i8> @abs_canonical_2_vec_undef_elts(<2 x i8> %x) {
+; CHECK-LABEL: @abs_canonical_2_vec_undef_elts(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 undef, i8 -1>
+; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
+; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[X]], <2 x i8> [[NEG]]
+; CHECK-NEXT: ret <2 x i8> [[ABS]]
+;
+ %cmp = icmp sgt <2 x i8> %x, <i8 undef, i8 -1>
+ %neg = sub <2 x i8> zeroinitializer, %x
+ %abs = select <2 x i1> %cmp, <2 x i8> %x, <2 x i8> %neg
+ ret <2 x i8> %abs
+}
+
; NSW should not change.
define i8 @abs_canonical_3(i8 %x) {
@@ -144,6 +159,21 @@ define <2 x i8> @nabs_canonical_2(<2 x i
%neg = sub <2 x i8> zeroinitializer, %x
%abs = select <2 x i1> %cmp, <2 x i8> %neg, <2 x i8> %x
ret <2 x i8> %abs
+}
+
+; Even if a constant has undef elements.
+
+define <2 x i8> @nabs_canonical_2_vec_undef_elts(<2 x i8> %x) {
+; CHECK-LABEL: @nabs_canonical_2_vec_undef_elts(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 -1, i8 undef>
+; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
+; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[NEG]], <2 x i8> [[X]]
+; CHECK-NEXT: ret <2 x i8> [[ABS]]
+;
+ %cmp = icmp sgt <2 x i8> %x, <i8 -1, i8 undef>
+ %neg = sub <2 x i8> zeroinitializer, %x
+ %abs = select <2 x i1> %cmp, <2 x i8> %neg, <2 x i8> %x
+ ret <2 x i8> %abs
}
; NSW should not change.
More information about the llvm-commits
mailing list