mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-02 00:16:25 +00:00
AMDGPU: Implement canonicalize
Also add generic DAG node for it. llvm-svn: 266272
This commit is contained in:
parent
ba8f42fa2c
commit
489a8fbeea
@ -257,6 +257,9 @@ namespace ISD {
|
|||||||
/// value as an integer 0/1 value.
|
/// value as an integer 0/1 value.
|
||||||
FGETSIGN,
|
FGETSIGN,
|
||||||
|
|
||||||
|
/// Returns platform specific canonical encoding of a floating point number.
|
||||||
|
FCANONICALIZE,
|
||||||
|
|
||||||
/// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the
|
/// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the
|
||||||
/// specified, possibly variable, elements. The number of elements is
|
/// specified, possibly variable, elements. The number of elements is
|
||||||
/// required to be a power of two. The types of the operands must all be
|
/// required to be a power of two. The types of the operands must all be
|
||||||
|
@ -434,6 +434,7 @@ def fmaxnum : SDNode<"ISD::FMAXNUM" , SDTFPBinOp,
|
|||||||
def fminnan : SDNode<"ISD::FMINNAN" , SDTFPBinOp>;
|
def fminnan : SDNode<"ISD::FMINNAN" , SDTFPBinOp>;
|
||||||
def fmaxnan : SDNode<"ISD::FMAXNAN" , SDTFPBinOp>;
|
def fmaxnan : SDNode<"ISD::FMAXNAN" , SDTFPBinOp>;
|
||||||
def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>;
|
def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>;
|
||||||
|
def fcanonicalize : SDNode<"ISD::FCANONICALIZE", SDTFPUnaryOp>;
|
||||||
def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
|
def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
|
||||||
def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
|
def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
|
||||||
def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
|
def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
|
||||||
|
@ -5120,7 +5120,8 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
|
|||||||
case Intrinsic::trunc:
|
case Intrinsic::trunc:
|
||||||
case Intrinsic::rint:
|
case Intrinsic::rint:
|
||||||
case Intrinsic::nearbyint:
|
case Intrinsic::nearbyint:
|
||||||
case Intrinsic::round: {
|
case Intrinsic::round:
|
||||||
|
case Intrinsic::canonicalize: {
|
||||||
unsigned Opcode;
|
unsigned Opcode;
|
||||||
switch (Intrinsic) {
|
switch (Intrinsic) {
|
||||||
default: llvm_unreachable("Impossible intrinsic"); // Can't reach here.
|
default: llvm_unreachable("Impossible intrinsic"); // Can't reach here.
|
||||||
@ -5134,6 +5135,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
|
|||||||
case Intrinsic::rint: Opcode = ISD::FRINT; break;
|
case Intrinsic::rint: Opcode = ISD::FRINT; break;
|
||||||
case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break;
|
case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break;
|
||||||
case Intrinsic::round: Opcode = ISD::FROUND; break;
|
case Intrinsic::round: Opcode = ISD::FROUND; break;
|
||||||
|
case Intrinsic::canonicalize: Opcode = ISD::FCANONICALIZE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(&I, DAG.getNode(Opcode, sdl,
|
setValue(&I, DAG.getNode(Opcode, sdl,
|
||||||
|
@ -202,6 +202,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
|
|||||||
case ISD::FREM: return "frem";
|
case ISD::FREM: return "frem";
|
||||||
case ISD::FCOPYSIGN: return "fcopysign";
|
case ISD::FCOPYSIGN: return "fcopysign";
|
||||||
case ISD::FGETSIGN: return "fgetsign";
|
case ISD::FGETSIGN: return "fgetsign";
|
||||||
|
case ISD::FCANONICALIZE: return "fcanonicalize";
|
||||||
case ISD::FPOW: return "fpow";
|
case ISD::FPOW: return "fpow";
|
||||||
case ISD::SMIN: return "smin";
|
case ISD::SMIN: return "smin";
|
||||||
case ISD::SMAX: return "smax";
|
case ISD::SMAX: return "smax";
|
||||||
|
@ -423,6 +423,7 @@ int TWO_PI_INV = 0x3e22f983;
|
|||||||
int FP_UINT_MAX_PLUS_1 = 0x4f800000; // 1 << 32 in floating point encoding
|
int FP_UINT_MAX_PLUS_1 = 0x4f800000; // 1 << 32 in floating point encoding
|
||||||
int FP32_NEG_ONE = 0xbf800000;
|
int FP32_NEG_ONE = 0xbf800000;
|
||||||
int FP32_ONE = 0x3f800000;
|
int FP32_ONE = 0x3f800000;
|
||||||
|
int FP64_ONE = 0x3ff0000000000000;
|
||||||
}
|
}
|
||||||
def CONST : Constants;
|
def CONST : Constants;
|
||||||
|
|
||||||
|
@ -281,6 +281,7 @@ SITargetLowering::SITargetLowering(TargetMachine &TM,
|
|||||||
setTargetDAGCombine(ISD::AND);
|
setTargetDAGCombine(ISD::AND);
|
||||||
setTargetDAGCombine(ISD::OR);
|
setTargetDAGCombine(ISD::OR);
|
||||||
setTargetDAGCombine(ISD::UINT_TO_FP);
|
setTargetDAGCombine(ISD::UINT_TO_FP);
|
||||||
|
setTargetDAGCombine(ISD::FCANONICALIZE);
|
||||||
|
|
||||||
// All memory operations. Some folding on the pointer operand is done to help
|
// All memory operations. Some folding on the pointer operand is done to help
|
||||||
// matching the constant offsets in the addressing modes.
|
// matching the constant offsets in the addressing modes.
|
||||||
@ -2400,6 +2401,46 @@ SDValue SITargetLowering::performClassCombine(SDNode *N,
|
|||||||
return SDValue();
|
return SDValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constant fold canonicalize.
|
||||||
|
SDValue SITargetLowering::performFCanonicalizeCombine(
|
||||||
|
SDNode *N,
|
||||||
|
DAGCombinerInfo &DCI) const {
|
||||||
|
ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(N->getOperand(0));
|
||||||
|
if (!CFP)
|
||||||
|
return SDValue();
|
||||||
|
|
||||||
|
SelectionDAG &DAG = DCI.DAG;
|
||||||
|
const APFloat &C = CFP->getValueAPF();
|
||||||
|
|
||||||
|
// Flush denormals to 0 if not enabled.
|
||||||
|
if (C.isDenormal()) {
|
||||||
|
EVT VT = N->getValueType(0);
|
||||||
|
if (VT == MVT::f32 && !Subtarget->hasFP32Denormals())
|
||||||
|
return DAG.getConstantFP(0.0, SDLoc(N), VT);
|
||||||
|
|
||||||
|
if (VT == MVT::f64 && !Subtarget->hasFP64Denormals())
|
||||||
|
return DAG.getConstantFP(0.0, SDLoc(N), VT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (C.isNaN()) {
|
||||||
|
EVT VT = N->getValueType(0);
|
||||||
|
APFloat CanonicalQNaN = APFloat::getQNaN(C.getSemantics());
|
||||||
|
if (C.isSignaling()) {
|
||||||
|
// Quiet a signaling NaN.
|
||||||
|
return DAG.getConstantFP(CanonicalQNaN, SDLoc(N), VT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure it is the canonical NaN bitpattern.
|
||||||
|
//
|
||||||
|
// TODO: Can we use -1 as the canonical NaN value since it's an inline
|
||||||
|
// immediate?
|
||||||
|
if (C.bitcastToAPInt() != CanonicalQNaN.bitcastToAPInt())
|
||||||
|
return DAG.getConstantFP(CanonicalQNaN, SDLoc(N), VT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDValue(CFP, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned minMaxOpcToMin3Max3Opc(unsigned Opc) {
|
static unsigned minMaxOpcToMin3Max3Opc(unsigned Opc) {
|
||||||
switch (Opc) {
|
switch (Opc) {
|
||||||
case ISD::FMAXNUM:
|
case ISD::FMAXNUM:
|
||||||
@ -2747,6 +2788,8 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
|
|||||||
return performOrCombine(N, DCI);
|
return performOrCombine(N, DCI);
|
||||||
case AMDGPUISD::FP_CLASS:
|
case AMDGPUISD::FP_CLASS:
|
||||||
return performClassCombine(N, DCI);
|
return performClassCombine(N, DCI);
|
||||||
|
case ISD::FCANONICALIZE:
|
||||||
|
return performFCanonicalizeCombine(N, DCI);
|
||||||
}
|
}
|
||||||
return AMDGPUTargetLowering::PerformDAGCombine(N, DCI);
|
return AMDGPUTargetLowering::PerformDAGCombine(N, DCI);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ class SITargetLowering final : public AMDGPUTargetLowering {
|
|||||||
SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
||||||
SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
SDValue performOrCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
||||||
SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
SDValue performClassCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
||||||
|
SDValue performFCanonicalizeCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
||||||
|
|
||||||
SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
SDValue performMinMaxCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
||||||
|
|
||||||
|
@ -3515,6 +3515,16 @@ def : Pat <
|
|||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def : Pat<
|
||||||
|
(fcanonicalize f32:$src),
|
||||||
|
(V_MUL_F32_e64 0, CONST.FP32_ONE, 0, $src, 0, 0)
|
||||||
|
>;
|
||||||
|
|
||||||
|
def : Pat<
|
||||||
|
(fcanonicalize f64:$src),
|
||||||
|
(V_MUL_F64 0, CONST.FP64_ONE, 0, $src, 0, 0)
|
||||||
|
>;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Fract Patterns
|
// Fract Patterns
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
320
test/CodeGen/AMDGPU/fcanonicalize.ll
Normal file
320
test/CodeGen/AMDGPU/fcanonicalize.ll
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
; RUN: llc -march=amdgcn -verify-machineinstrs -mattr=-fp32-denormals,-fp64-denormals < %s | FileCheck -check-prefix=GCN -check-prefix=NODENORM %s
|
||||||
|
; RUN: llc -march=amdgcn -verify-machineinstrs -mattr=+fp32-denormals,+fp64-denormals < %s | FileCheck -check-prefix=GCN -check-prefix=DENORM %s
|
||||||
|
|
||||||
|
declare float @llvm.canonicalize.f32(float) #0
|
||||||
|
declare double @llvm.canonicalize.f64(double) #0
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}v_test_canonicalize_var_f32:
|
||||||
|
; GCN: v_mul_f32_e32 [[REG:v[0-9]+]], 1.0, {{v[0-9]+}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @v_test_canonicalize_var_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%val = load float, float addrspace(1)* %out
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float %val)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}s_test_canonicalize_var_f32:
|
||||||
|
; GCN: v_mul_f32_e64 [[REG:v[0-9]+]], 1.0, {{s[0-9]+}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @s_test_canonicalize_var_f32(float addrspace(1)* %out, float %val) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float %val)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_p0_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_p0_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float 0.0)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_n0_f32:
|
||||||
|
; GCN: v_bfrev_b32_e32 [[REG:v[0-9]+]], 1{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_n0_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float -0.0)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_p1_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 1.0{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_p1_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float 1.0)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_n1_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], -1.0{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_n1_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float -1.0)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_literal_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x41800000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_literal_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float 16.0)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_denormal0_f32:
|
||||||
|
; NODENORM: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}}
|
||||||
|
; DENORM: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fffff{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_denormal0_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 8388607 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_denormal1_f32:
|
||||||
|
; NODENORM: v_mov_b32_e32 [[REG:v[0-9]+]], 0{{$}}
|
||||||
|
; DENORM: v_mov_b32_e32 [[REG:v[0-9]+]], 0x807fffff{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_denormal1_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2155872255 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_qnan_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float 0x7FF8000000000000)
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg1_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_qnan_value_neg1_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 -1 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg2_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_qnan_value_neg2_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 -2 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan0_value_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_snan0_value_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2139095041 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan1_value_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_snan1_value_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 2143289343 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan2_value_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_snan2_value_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 4286578689 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan3_value_f32:
|
||||||
|
; GCN: v_mov_b32_e32 [[REG:v[0-9]+]], 0x7fc00000{{$}}
|
||||||
|
; GCN: buffer_store_dword [[REG]]
|
||||||
|
define void @test_fold_canonicalize_snan3_value_f32(float addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call float @llvm.canonicalize.f32(float bitcast (i32 4290772991 to float))
|
||||||
|
store float %canonicalized, float addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}v_test_canonicalize_var_f64:
|
||||||
|
; GCN: v_mul_f64 [[REG:v\[[0-9]+:[0-9]+\]]], 1.0, {{v\[[0-9]+:[0-9]+\]}}
|
||||||
|
; GCN: buffer_store_dwordx2 [[REG]]
|
||||||
|
define void @v_test_canonicalize_var_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%val = load double, double addrspace(1)* %out
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double %val)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}s_test_canonicalize_var_f64:
|
||||||
|
; GCN: v_mul_f64 [[REG:v\[[0-9]+:[0-9]+\]]], 1.0, {{s\[[0-9]+:[0-9]+\]}}
|
||||||
|
; GCN: buffer_store_dwordx2 [[REG]]
|
||||||
|
define void @s_test_canonicalize_var_f64(double addrspace(1)* %out, double %val) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double %val)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_p0_f64:
|
||||||
|
; GCN: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: v_mov_b32_e32 v[[HI:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_p0_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double 0.0)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_n0_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN-DAG: v_bfrev_b32_e32 v[[HI:[0-9]+]], 1{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_n0_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double -0.0)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_p1_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x3ff00000{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_p1_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double 1.0)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_n1_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0xbff00000{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_n1_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double -1.0)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_literal_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x40300000{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_literal_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double 16.0)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_denormal0_f64:
|
||||||
|
; DENORM-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], -1{{$}}
|
||||||
|
; DENORM-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0xfffff{{$}}
|
||||||
|
|
||||||
|
; NODENORM: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; NODENORM: v_mov_b32_e32 v[[HI:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_denormal0_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 4503599627370495 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_denormal1_f64:
|
||||||
|
; DENORM-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], -1{{$}}
|
||||||
|
; DENORM-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x800fffff{{$}}
|
||||||
|
|
||||||
|
; NODENORM: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; NODENORM: v_mov_b32_e32 v[[HI:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_denormal1_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9227875636482146303 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_qnan_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double 0x7FF8000000000000)
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg1_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_qnan_value_neg1_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 -1 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_qnan_value_neg2_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_qnan_value_neg2_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 -2 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan0_value_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_snan0_value_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9218868437227405313 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan1_value_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_snan1_value_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 9223372036854775807 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan2_value_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_snan2_value_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 18442240474082181121 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}test_fold_canonicalize_snan3_value_f64:
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x7ff80000{{$}}
|
||||||
|
; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}}
|
||||||
|
; GCN: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
|
||||||
|
define void @test_fold_canonicalize_snan3_value_f64(double addrspace(1)* %out) #1 {
|
||||||
|
%canonicalized = call double @llvm.canonicalize.f64(double bitcast (i64 18446744073709551615 to double))
|
||||||
|
store double %canonicalized, double addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { nounwind readnone }
|
||||||
|
attributes #1 = { nounwind }
|
Loading…
Reference in New Issue
Block a user