[llvm] r266272 - AMDGPU: Implement canonicalize
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 18:42:17 PDT 2016
Author: arsenm
Date: Wed Apr 13 20:42:16 2016
New Revision: 266272
URL: http://llvm.org/viewvc/llvm-project?rev=266272&view=rev
Log:
AMDGPU: Implement canonicalize
Also add generic DAG node for it.
Added:
llvm/trunk/test/CodeGen/AMDGPU/fcanonicalize.ll
Modified:
llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h
llvm/trunk/include/llvm/Target/TargetSelectionDAG.td
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td
llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/trunk/lib/Target/AMDGPU/SIISelLowering.h
llvm/trunk/lib/Target/AMDGPU/SIInstructions.td
Modified: llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h Wed Apr 13 20:42:16 2016
@@ -257,6 +257,9 @@ namespace ISD {
/// value as an integer 0/1 value.
FGETSIGN,
+ /// Returns platform specific canonical encoding of a floating point number.
+ FCANONICALIZE,
+
/// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the
/// specified, possibly variable, elements. The number of elements is
/// required to be a power of two. The types of the operands must all be
Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSelectionDAG.td?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetSelectionDAG.td (original)
+++ llvm/trunk/include/llvm/Target/TargetSelectionDAG.td Wed Apr 13 20:42:16 2016
@@ -434,6 +434,7 @@ def fmaxnum : SDNode<"ISD::FMAXNUM"
def fminnan : SDNode<"ISD::FMINNAN" , SDTFPBinOp>;
def fmaxnan : SDNode<"ISD::FMAXNAN" , SDTFPBinOp>;
def fgetsign : SDNode<"ISD::FGETSIGN" , SDTFPToIntOp>;
+def fcanonicalize : SDNode<"ISD::FCANONICALIZE", SDTFPUnaryOp>;
def fneg : SDNode<"ISD::FNEG" , SDTFPUnaryOp>;
def fsqrt : SDNode<"ISD::FSQRT" , SDTFPUnaryOp>;
def fsin : SDNode<"ISD::FSIN" , SDTFPUnaryOp>;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Apr 13 20:42:16 2016
@@ -5120,7 +5120,8 @@ SelectionDAGBuilder::visitIntrinsicCall(
case Intrinsic::trunc:
case Intrinsic::rint:
case Intrinsic::nearbyint:
- case Intrinsic::round: {
+ case Intrinsic::round:
+ case Intrinsic::canonicalize: {
unsigned Opcode;
switch (Intrinsic) {
default: llvm_unreachable("Impossible intrinsic"); // Can't reach here.
@@ -5134,6 +5135,7 @@ SelectionDAGBuilder::visitIntrinsicCall(
case Intrinsic::rint: Opcode = ISD::FRINT; break;
case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break;
case Intrinsic::round: Opcode = ISD::FROUND; break;
+ case Intrinsic::canonicalize: Opcode = ISD::FCANONICALIZE; break;
}
setValue(&I, DAG.getNode(Opcode, sdl,
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp Wed Apr 13 20:42:16 2016
@@ -202,6 +202,7 @@ std::string SDNode::getOperationName(con
case ISD::FREM: return "frem";
case ISD::FCOPYSIGN: return "fcopysign";
case ISD::FGETSIGN: return "fgetsign";
+ case ISD::FCANONICALIZE: return "fcanonicalize";
case ISD::FPOW: return "fpow";
case ISD::SMIN: return "smin";
case ISD::SMAX: return "smax";
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td Wed Apr 13 20:42:16 2016
@@ -423,6 +423,7 @@ int TWO_PI_INV = 0x3e22f983;
int FP_UINT_MAX_PLUS_1 = 0x4f800000; // 1 << 32 in floating point encoding
int FP32_NEG_ONE = 0xbf800000;
int FP32_ONE = 0x3f800000;
+int FP64_ONE = 0x3ff0000000000000;
}
def CONST : Constants;
Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp Wed Apr 13 20:42:16 2016
@@ -281,6 +281,7 @@ SITargetLowering::SITargetLowering(Targe
setTargetDAGCombine(ISD::AND);
setTargetDAGCombine(ISD::OR);
setTargetDAGCombine(ISD::UINT_TO_FP);
+ setTargetDAGCombine(ISD::FCANONICALIZE);
// All memory operations. Some folding on the pointer operand is done to help
// matching the constant offsets in the addressing modes.
@@ -2400,6 +2401,46 @@ SDValue SITargetLowering::performClassCo
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) {
switch (Opc) {
case ISD::FMAXNUM:
@@ -2747,6 +2788,8 @@ SDValue SITargetLowering::PerformDAGComb
return performOrCombine(N, DCI);
case AMDGPUISD::FP_CLASS:
return performClassCombine(N, DCI);
+ case ISD::FCANONICALIZE:
+ return performFCanonicalizeCombine(N, DCI);
}
return AMDGPUTargetLowering::PerformDAGCombine(N, DCI);
}
Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.h?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.h Wed Apr 13 20:42:16 2016
@@ -55,6 +55,7 @@ class SITargetLowering final : public AM
SDValue performAndCombine(SDNode *N, DAGCombinerInfo &DCI) const;
SDValue performOrCombine(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;
Modified: llvm/trunk/lib/Target/AMDGPU/SIInstructions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIInstructions.td?rev=266272&r1=266271&r2=266272&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIInstructions.td (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIInstructions.td Wed Apr 13 20:42:16 2016
@@ -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
//===----------------------------------------------------------------------===//
Added: llvm/trunk/test/CodeGen/AMDGPU/fcanonicalize.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/fcanonicalize.ll?rev=266272&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/fcanonicalize.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/fcanonicalize.ll Wed Apr 13 20:42:16 2016
@@ -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 }
More information about the llvm-commits
mailing list