Skip to content

Commit 48809fa

Browse files
authored
Remove unused variable, and unneeded extract element instruction (#103489)
This PR removes an unneeded extract element instruction from codegen, along with the variable that captured that instruction's return value.
1 parent f1779ae commit 48809fa

File tree

3 files changed

+1
-8
lines changed

3 files changed

+1
-8
lines changed

clang/test/SemaHLSL/BuiltIns/normalize-errors.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -verify-ignore-unexpected
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected
22

33
void test_too_few_arg()
44
{

llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ static bool expandNormalizeIntrinsic(CallInst *Orig) {
252252
return true;
253253
}
254254

255-
Value *Elt = Builder.CreateExtractElement(X, (uint64_t)0);
256255
unsigned XVecSize = XVec->getNumElements();
257256
Value *DotProduct = nullptr;
258257
// use the dot intrinsic corresponding to the vector size

llvm/test/CodeGen/DirectX/normalize.ll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ entry:
2222

2323
define noundef <2 x half> @test_normalize_half2(<2 x half> noundef %p0) {
2424
entry:
25-
; CHECK: extractelement <2 x half> %{{.*}}, i64 0
2625
; EXPCHECK: [[doth2:%.*]] = call half @llvm.dx.dot2.v2f16(<2 x half> %{{.*}}, <2 x half> %{{.*}})
2726
; DOPCHECK: [[doth2:%.*]] = call half @dx.op.dot2.f16(i32 54, half %{{.*}}, half %{{.*}}, half %{{.*}}, half %{{.*}})
2827
; EXPCHECK: [[rsqrt:%.*]] = call half @llvm.dx.rsqrt.f16(half [[doth2]])
@@ -37,7 +36,6 @@ entry:
3736

3837
define noundef <3 x half> @test_normalize_half3(<3 x half> noundef %p0) {
3938
entry:
40-
; CHECK: extractelement <3 x half> %{{.*}}, i64 0
4139
; EXPCHECK: [[doth3:%.*]] = call half @llvm.dx.dot3.v3f16(<3 x half> %{{.*}}, <3 x half> %{{.*}})
4240
; DOPCHECK: [[doth3:%.*]] = call half @dx.op.dot3.f16(i32 55, half %{{.*}}, half %{{.*}}, half %{{.*}}, half %{{.*}})
4341
; EXPCHECK: [[rsqrt:%.*]] = call half @llvm.dx.rsqrt.f16(half [[doth3]])
@@ -52,7 +50,6 @@ entry:
5250

5351
define noundef <4 x half> @test_normalize_half4(<4 x half> noundef %p0) {
5452
entry:
55-
; CHECK: extractelement <4 x half> %{{.*}}, i64 0
5653
; EXPCHECK: [[doth4:%.*]] = call half @llvm.dx.dot4.v4f16(<4 x half> %{{.*}}, <4 x half> %{{.*}})
5754
; DOPCHECK: [[doth4:%.*]] = call half @dx.op.dot4.f16(i32 56, half %{{.*}}, half %{{.*}}, half %{{.*}}, half %{{.*}})
5855
; EXPCHECK: [[rsqrt:%.*]] = call half @llvm.dx.rsqrt.f16(half [[doth4]])
@@ -74,7 +71,6 @@ entry:
7471

7572
define noundef <2 x float> @test_normalize_float2(<2 x float> noundef %p0) {
7673
entry:
77-
; CHECK: extractelement <2 x float> %{{.*}}, i64 0
7874
; EXPCHECK: [[dotf2:%.*]] = call float @llvm.dx.dot2.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}})
7975
; DOPCHECK: [[dotf2:%.*]] = call float @dx.op.dot2.f32(i32 54, float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
8076
; EXPCHECK: [[rsqrt:%.*]] = call float @llvm.dx.rsqrt.f32(float [[dotf2]])
@@ -89,7 +85,6 @@ entry:
8985

9086
define noundef <3 x float> @test_normalize_float3(<3 x float> noundef %p0) {
9187
entry:
92-
; CHECK: extractelement <3 x float> %{{.*}}, i64 0
9388
; EXPCHECK: [[dotf3:%.*]] = call float @llvm.dx.dot3.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}})
9489
; DOPCHECK: [[dotf3:%.*]] = call float @dx.op.dot3.f32(i32 55, float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
9590
; EXPCHECK: [[rsqrt:%.*]] = call float @llvm.dx.rsqrt.f32(float [[dotf3]])
@@ -104,7 +99,6 @@ entry:
10499

105100
define noundef <4 x float> @test_normalize_float4(<4 x float> noundef %p0) {
106101
entry:
107-
; CHECK: extractelement <4 x float> %{{.*}}, i64 0
108102
; EXPCHECK: [[dotf4:%.*]] = call float @llvm.dx.dot4.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}})
109103
; DOPCHECK: [[dotf4:%.*]] = call float @dx.op.dot4.f32(i32 56, float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
110104
; EXPCHECK: [[rsqrt:%.*]] = call float @llvm.dx.rsqrt.f32(float [[dotf4]])

0 commit comments

Comments
 (0)