-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DirectX backend] avoid generate redundant bitcast in DXILPrepareModu…
…le (#65163) When emit NoOp bitcast for GEP Ptr Operand, should use SourceElementType instead of ResultElementType. **Behavior Before Change** Redundant bitcast like ` bitcast ptr addrspace(3) @gs to ptr addrspace(3)` will be generated for llvm/test/CodeGen/DirectX/typed_ptr.ll **Behavior After Change** No bitcast will be generated. Fixes #65183
- Loading branch information
1 parent
69d79f1
commit c21cd16
Showing
2 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
; RUN: opt -S -dxil-prepare < %s | FileCheck %s | ||
target triple = "dxil-unknown-unknown" | ||
|
||
; Make sure not crash when has typed ptr. | ||
; CHECK:@test | ||
@gs = external addrspace(3) global [20 x [6 x float]], align 4 | ||
|
||
; Make sure not crash when has typed ptr. | ||
define i64 @test(i64* %p) { | ||
; CHECK-LABEL: define i64 @test( | ||
; CHECK-SAME: ptr [[P:%.*]]) { | ||
; CHECK-NEXT: [[V:%.*]] = load i64, ptr [[P]], align 4 | ||
; CHECK-NEXT: ret i64 [[V]] | ||
; | ||
%v = load i64, i64* %p | ||
ret i64 %v | ||
} | ||
|
||
; Make sure no bitcast generated. | ||
define void @test_gep() { | ||
; CHECK-LABEL: define void @test_gep() { | ||
; CHECK-NEXT: [[BASE:%.*]] = getelementptr inbounds [20 x [6 x float]], ptr addrspace(3) @gs, i64 0, i64 3 | ||
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr inbounds [6 x float], ptr addrspace(3) [[BASE]], i64 0, i64 2 | ||
; CHECK-NEXT: store float 1.000000e+00, ptr addrspace(3) [[ADDR]], align 4 | ||
; CHECK-NEXT: ret void | ||
; | ||
%base = getelementptr inbounds [20 x [6 x float]], ptr addrspace(3) @gs, i64 0, i64 3 | ||
%addr = getelementptr inbounds [6 x float], ptr addrspace(3) %base, i64 0, i64 2 | ||
store float 1.000000e+00, ptr addrspace(3) %addr, align 4 | ||
ret void | ||
} |