@@ -51,5 +51,37 @@ entry:
51
51
ret half %elt.atan2
52
52
}
53
53
54
+ define noundef <4 x float > @atan2_float4 (<4 x float > noundef %y , <4 x float > noundef %x ) {
55
+ entry:
56
+ ; Just Expansion, no scalarization or lowering:
57
+ ; EXPCHECK: [[DIV:%.+]] = fdiv <4 x float> %y, %x
58
+ ; EXPCHECK: [[ATAN:%.+]] = call <4 x float> @llvm.atan.v4f32(<4 x float> [[DIV]])
59
+ ; EXPCHECK-DAG: [[ADD_PI:%.+]] = fadd <4 x float> [[ATAN]], <float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000>
60
+ ; EXPCHECK-DAG: [[SUB_PI:%.+]] = fsub <4 x float> [[ATAN]], <float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000>
61
+ ; EXPCHECK-DAG: [[X_LT_0:%.+]] = fcmp olt <4 x float> %x, zeroinitializer
62
+ ; EXPCHECK-DAG: [[X_EQ_0:%.+]] = fcmp oeq <4 x float> %x, zeroinitializer
63
+ ; EXPCHECK-DAG: [[Y_GE_0:%.+]] = fcmp oge <4 x float> %y, zeroinitializer
64
+ ; EXPCHECK-DAG: [[Y_LT_0:%.+]] = fcmp olt <4 x float> %y, zeroinitializer
65
+ ; EXPCHECK: [[XLT0_AND_YGE0:%.+]] = and <4 x i1> [[X_LT_0]], [[Y_GE_0]]
66
+ ; EXPCHECK: [[SELECT_ADD_PI:%.+]] = select <4 x i1> [[XLT0_AND_YGE0]], <4 x float> [[ADD_PI]], <4 x float> [[ATAN]]
67
+ ; EXPCHECK: [[XLT0_AND_YLT0:%.+]] = and <4 x i1> [[X_LT_0]], [[Y_LT_0]]
68
+ ; EXPCHECK: [[SELECT_SUB_PI:%.+]] = select <4 x i1> [[XLT0_AND_YLT0]], <4 x float> [[SUB_PI]], <4 x float> [[SELECT_ADD_PI]]
69
+ ; EXPCHECK: [[XEQ0_AND_YLT0:%.+]] = and <4 x i1> [[X_EQ_0]], [[Y_LT_0]]
70
+ ; EXPCHECK: [[SELECT_NEGHPI:%.+]] = select <4 x i1> [[XEQ0_AND_YLT0]], <4 x float> <float 0xBFF921FB60000000, float 0xBFF921FB60000000, float 0xBFF921FB60000000, float 0xBFF921FB60000000>, <4 x float> [[SELECT_SUB_PI]]
71
+ ; EXPCHECK: [[XEQ0_AND_YGE0:%.+]] = and <4 x i1> [[X_EQ_0]], [[Y_GE_0]]
72
+ ; EXPCHECK: [[SELECT_HPI:%.+]] = select <4 x i1> [[XEQ0_AND_YGE0]], <4 x float> <float 0x3FF921FB60000000, float 0x3FF921FB60000000, float 0x3FF921FB60000000, float 0x3FF921FB60000000>, <4 x float> [[SELECT_NEGHPI]]
73
+ ; EXPCHECK: ret <4 x float> [[SELECT_HPI]]
74
+
75
+ ; Scalarization occurs after expansion, so atan scalarization is tested separately.
76
+ ; Expansion, scalarization and lowering:
77
+ ; Just make sure this expands to exactly 4 scalar DXIL atan (OpCode=17) calls.
78
+ ; DOPCHECK-COUNT-4: call float @dx.op.unary.f32(i32 17, float %{{.*}})
79
+ ; DOPCHECK-NOT: call float @dx.op.unary.f32(i32 17,
80
+
81
+ %elt.atan2 = call <4 x float > @llvm.atan2.v4f32 (<4 x float > %y , <4 x float > %x )
82
+ ret <4 x float > %elt.atan2
83
+ }
84
+
54
85
declare half @llvm.atan2.f16 (half , half )
55
86
declare float @llvm.atan2.f32 (float , float )
87
+ declare <4 x float > @llvm.atan2.v4f32 (<4 x float >, <4 x float >)
0 commit comments