1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[ValueTracking] Improve isKnownNonNaN() to recognize zero splats.

isKnownNonNaN() could not recognize a zero splat because that is a
ConstantAggregateZero which is-a ConstantData but not a ConstantDataVector.

Patch makes a ConstantAggregateZero return true.

Review: Thomas Lively

Differential Revision: https://reviews.llvm.org/D74263
This commit is contained in:
Jonas Paulsson 2020-02-06 19:27:50 +01:00
parent b49202c11d
commit 9dcacebd4c
2 changed files with 86 additions and 0 deletions

View File

@ -4787,6 +4787,9 @@ static bool isKnownNonNaN(const Value *V, FastMathFlags FMF) {
return true;
}
if (isa<ConstantAggregateZero>(V))
return true;
return false;
}

View File

@ -0,0 +1,83 @@
; Test vector maximum/minimum with a zero splat on z14.
;
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
define <2 x double> @f1(<2 x double> %val) {
; CHECK-LABEL: f1:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfmaxdb %v24, %v24, %v0, 4
; CHECK-NEXT: br %r14
%cmp = fcmp ogt <2 x double> %val, zeroinitializer
%ret = select <2 x i1> %cmp, <2 x double> %val, <2 x double> zeroinitializer
ret <2 x double> %ret
}
define <2 x double> @f2(<2 x double> %val) {
; CHECK-LABEL: f2:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfmindb %v24, %v24, %v0, 4
; CHECK-NEXT: br %r14
%cmp = fcmp olt <2 x double> %val, zeroinitializer
%ret = select <2 x i1> %cmp, <2 x double> %val, <2 x double> zeroinitializer
ret <2 x double> %ret
}
define <4 x float> @f3(<4 x float> %val) {
; CHECK-LABEL: f3:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfmaxsb %v24, %v24, %v0, 4
; CHECK-NEXT: br %r14
%cmp = fcmp ogt <4 x float> %val, zeroinitializer
%ret = select <4 x i1> %cmp, <4 x float> %val, <4 x float> zeroinitializer
ret <4 x float> %ret
}
define <4 x float> @f4(<4 x float> %val) {
; CHECK-LABEL: f4:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfminsb %v24, %v24, %v0, 4
; CHECK-NEXT: br %r14
%cmp = fcmp olt <4 x float> %val, zeroinitializer
%ret = select <4 x i1> %cmp, <4 x float> %val, <4 x float> zeroinitializer
ret <4 x float> %ret
}
define <2 x double> @f5(<2 x double> %val) {
; CHECK-LABEL: f5:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfmaxdb %v24, %v24, %v0, 1
; CHECK-NEXT: br %r14
%cmp = fcmp ugt <2 x double> %val, zeroinitializer
%ret = select <2 x i1> %cmp, <2 x double> %val, <2 x double> zeroinitializer
ret <2 x double> %ret
}
define <2 x double> @f6(<2 x double> %val) {
; CHECK-LABEL: f6:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfmindb %v24, %v24, %v0, 1
; CHECK-NEXT: br %r14
%cmp = fcmp ult <2 x double> %val, zeroinitializer
%ret = select <2 x i1> %cmp, <2 x double> %val, <2 x double> zeroinitializer
ret <2 x double> %ret
}
define <4 x float> @f7(<4 x float> %val) {
; CHECK-LABEL: f7:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfmaxsb %v24, %v24, %v0, 1
; CHECK-NEXT: br %r14
%cmp = fcmp ugt <4 x float> %val, zeroinitializer
%ret = select <4 x i1> %cmp, <4 x float> %val, <4 x float> zeroinitializer
ret <4 x float> %ret
}
define <4 x float> @f8(<4 x float> %val) {
; CHECK-LABEL: f8:
; CHECK: vgbm %v0, 0
; CHECK-NEXT: vfminsb %v24, %v24, %v0, 1
; CHECK-NEXT: br %r14
%cmp = fcmp ult <4 x float> %val, zeroinitializer
%ret = select <4 x i1> %cmp, <4 x float> %val, <4 x float> zeroinitializer
ret <4 x float> %ret
}