[llvm] 849d577 - [x86] add tests for fcmp with 0.0 operand; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 06:04:39 PDT 2022
Author: Sanjay Patel
Date: 2022-03-30T08:37:15-04:00
New Revision: 849d577e564225d498a35dac920fb0899c299b12
URL: https://github.com/llvm/llvm-project/commit/849d577e564225d498a35dac920fb0899c299b12
DIFF: https://github.com/llvm/llvm-project/commit/849d577e564225d498a35dac920fb0899c299b12.diff
LOG: [x86] add tests for fcmp with 0.0 operand; NFC
Added:
Modified:
llvm/test/CodeGen/X86/setcc-combine.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/setcc-combine.ll b/llvm/test/CodeGen/X86/setcc-combine.ll
index 85b920b2aea98..33d58ca018f0f 100644
--- a/llvm/test/CodeGen/X86/setcc-combine.ll
+++ b/llvm/test/CodeGen/X86/setcc-combine.ll
@@ -359,3 +359,184 @@ define i64 @sub_constant_to_shift_to_add(i32 %x, i64 %s1, i64 %s2) {
ret i64 %r
}
+define float @olt(float %x) {
+; CHECK-LABEL: olt:
+; CHECK: # %bb.0:
+; CHECK-NEXT: movaps {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
+; CHECK-NEXT: xorps %xmm0, %xmm1
+; CHECK-NEXT: xorps %xmm2, %xmm2
+; CHECK-NEXT: movaps %xmm0, %xmm3
+; CHECK-NEXT: cmpltss %xmm2, %xmm3
+; CHECK-NEXT: andps %xmm3, %xmm0
+; CHECK-NEXT: andnps %xmm1, %xmm3
+; CHECK-NEXT: orps %xmm3, %xmm0
+; CHECK-NEXT: retq
+ %cmp = fcmp olt float %x, 0.0
+ %neg = fneg float %x
+ %r = select i1 %cmp, float %x, float %neg
+ ret float %r
+}
+
+define double @ogt(double %x) {
+; CHECK-LABEL: ogt:
+; CHECK: # %bb.0:
+; CHECK-NEXT: movapd {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0]
+; CHECK-NEXT: xorpd %xmm0, %xmm1
+; CHECK-NEXT: xorpd %xmm2, %xmm2
+; CHECK-NEXT: cmpltsd %xmm0, %xmm2
+; CHECK-NEXT: andpd %xmm2, %xmm0
+; CHECK-NEXT: andnpd %xmm1, %xmm2
+; CHECK-NEXT: orpd %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %neg = fneg double %x
+ %cmp = fcmp ogt double %x, 0.0
+ %r = select i1 %cmp, double %x, double %neg
+ ret double %r
+}
+
+define <4 x float> @olt_swap(<4 x float> %x) {
+; SSE2-LABEL: olt_swap:
+; SSE2: # %bb.0:
+; SSE2-NEXT: xorps %xmm1, %xmm1
+; SSE2-NEXT: movaps %xmm0, %xmm2
+; SSE2-NEXT: cmpltps %xmm1, %xmm2
+; SSE2-NEXT: movaps %xmm2, %xmm1
+; SSE2-NEXT: andnps %xmm0, %xmm1
+; SSE2-NEXT: xorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; SSE2-NEXT: andps %xmm2, %xmm0
+; SSE2-NEXT: orps %xmm1, %xmm0
+; SSE2-NEXT: retq
+;
+; SSE41-LABEL: olt_swap:
+; SSE41: # %bb.0:
+; SSE41-NEXT: movaps %xmm0, %xmm1
+; SSE41-NEXT: xorps %xmm2, %xmm2
+; SSE41-NEXT: cmpltps %xmm2, %xmm0
+; SSE41-NEXT: movaps {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
+; SSE41-NEXT: xorps %xmm1, %xmm2
+; SSE41-NEXT: blendvps %xmm0, %xmm2, %xmm1
+; SSE41-NEXT: movaps %xmm1, %xmm0
+; SSE41-NEXT: retq
+ %cmp = fcmp olt <4 x float> %x, zeroinitializer
+ %neg = fneg <4 x float> %x
+ %r = select <4 x i1> %cmp, <4 x float> %neg, <4 x float> %x
+ ret <4 x float> %r
+}
+
+define <2 x double> @ogt_swap(<2 x double> %x) {
+; SSE2-LABEL: ogt_swap:
+; SSE2: # %bb.0:
+; SSE2-NEXT: movapd {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0]
+; SSE2-NEXT: xorpd %xmm0, %xmm2
+; SSE2-NEXT: xorpd %xmm1, %xmm1
+; SSE2-NEXT: cmpltpd %xmm0, %xmm1
+; SSE2-NEXT: andpd %xmm1, %xmm2
+; SSE2-NEXT: andnpd %xmm0, %xmm1
+; SSE2-NEXT: orpd %xmm2, %xmm1
+; SSE2-NEXT: movapd %xmm1, %xmm0
+; SSE2-NEXT: retq
+;
+; SSE41-LABEL: ogt_swap:
+; SSE41: # %bb.0:
+; SSE41-NEXT: movapd %xmm0, %xmm1
+; SSE41-NEXT: movapd {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0]
+; SSE41-NEXT: xorpd %xmm0, %xmm2
+; SSE41-NEXT: xorpd %xmm0, %xmm0
+; SSE41-NEXT: cmpltpd %xmm1, %xmm0
+; SSE41-NEXT: blendvpd %xmm0, %xmm2, %xmm1
+; SSE41-NEXT: movapd %xmm1, %xmm0
+; SSE41-NEXT: retq
+ %neg = fneg <2 x double> %x
+ %cmp = fcmp ogt <2 x double> %x, zeroinitializer
+ %r = select <2 x i1> %cmp, <2 x double> %neg, <2 x double> %x
+ ret <2 x double> %r
+}
+
+define <4 x float> @ole(<4 x float> %x) {
+; SSE2-LABEL: ole:
+; SSE2: # %bb.0:
+; SSE2-NEXT: xorps %xmm1, %xmm1
+; SSE2-NEXT: movaps %xmm0, %xmm2
+; SSE2-NEXT: cmpleps %xmm1, %xmm2
+; SSE2-NEXT: movaps %xmm2, %xmm1
+; SSE2-NEXT: andnps %xmm0, %xmm1
+; SSE2-NEXT: xorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; SSE2-NEXT: andps %xmm2, %xmm0
+; SSE2-NEXT: orps %xmm1, %xmm0
+; SSE2-NEXT: retq
+;
+; SSE41-LABEL: ole:
+; SSE41: # %bb.0:
+; SSE41-NEXT: movaps %xmm0, %xmm1
+; SSE41-NEXT: xorps %xmm2, %xmm2
+; SSE41-NEXT: cmpleps %xmm2, %xmm0
+; SSE41-NEXT: movaps {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
+; SSE41-NEXT: xorps %xmm1, %xmm2
+; SSE41-NEXT: blendvps %xmm0, %xmm2, %xmm1
+; SSE41-NEXT: movaps %xmm1, %xmm0
+; SSE41-NEXT: retq
+ %cmp = fcmp ole <4 x float> %x, zeroinitializer
+ %neg = fneg <4 x float> %x
+ %r = select <4 x i1> %cmp, <4 x float> %neg, <4 x float> %x
+ ret <4 x float> %r
+}
+
+define <2 x double> @oge(<2 x double> %x) {
+; SSE2-LABEL: oge:
+; SSE2: # %bb.0:
+; SSE2-NEXT: movapd {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0]
+; SSE2-NEXT: xorpd %xmm0, %xmm2
+; SSE2-NEXT: xorpd %xmm1, %xmm1
+; SSE2-NEXT: cmplepd %xmm0, %xmm1
+; SSE2-NEXT: andpd %xmm1, %xmm2
+; SSE2-NEXT: andnpd %xmm0, %xmm1
+; SSE2-NEXT: orpd %xmm2, %xmm1
+; SSE2-NEXT: movapd %xmm1, %xmm0
+; SSE2-NEXT: retq
+;
+; SSE41-LABEL: oge:
+; SSE41: # %bb.0:
+; SSE41-NEXT: movapd %xmm0, %xmm1
+; SSE41-NEXT: movapd {{.*#+}} xmm2 = [-0.0E+0,-0.0E+0]
+; SSE41-NEXT: xorpd %xmm0, %xmm2
+; SSE41-NEXT: xorpd %xmm0, %xmm0
+; SSE41-NEXT: cmplepd %xmm1, %xmm0
+; SSE41-NEXT: blendvpd %xmm0, %xmm2, %xmm1
+; SSE41-NEXT: movapd %xmm1, %xmm0
+; SSE41-NEXT: retq
+ %neg = fneg <2 x double> %x
+ %cmp = fcmp oge <2 x double> %x, zeroinitializer
+ %r = select <2 x i1> %cmp, <2 x double> %neg, <2 x double> %x
+ ret <2 x double> %r
+}
+
+define double @ogt_no_fneg(double %x, double %y) {
+; CHECK-LABEL: ogt_no_fneg:
+; CHECK: # %bb.0:
+; CHECK-NEXT: xorpd %xmm2, %xmm2
+; CHECK-NEXT: cmpltsd %xmm0, %xmm2
+; CHECK-NEXT: andpd %xmm2, %xmm0
+; CHECK-NEXT: andnpd %xmm1, %xmm2
+; CHECK-NEXT: orpd %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %cmp = fcmp ogt double %x, 0.0
+ %r = select i1 %cmp, double %x, double %y
+ ret double %r
+}
+
+define double @ogt_no_zero(double %x) {
+; CHECK-LABEL: ogt_no_zero:
+; CHECK: # %bb.0:
+; CHECK-NEXT: movapd {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0]
+; CHECK-NEXT: xorpd %xmm0, %xmm1
+; CHECK-NEXT: movsd {{.*#+}} xmm2 = mem[0],zero
+; CHECK-NEXT: cmpltsd %xmm0, %xmm2
+; CHECK-NEXT: andpd %xmm2, %xmm0
+; CHECK-NEXT: andnpd %xmm1, %xmm2
+; CHECK-NEXT: orpd %xmm2, %xmm0
+; CHECK-NEXT: retq
+ %neg = fneg double %x
+ %cmp = fcmp ogt double %x, 1.0
+ %r = select i1 %cmp, double %x, double %neg
+ ret double %r
+}
More information about the llvm-commits
mailing list