-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[Scalarizer][DirectX] support structs return types #111569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9a5042f
[Scalarizer] A change to let the scalarizer pass be able to scalarize…
farzonl da2e3c1
Add support for frexp. Move vector look up to just callInst and extra…
farzonl c5383f3
fix up in prep for PR.
farzonl 8f7ed3b
address pr comments
farzonl dfa4963
add safety check in case `getVectorSplit` fails.
farzonl 5e8cb8b
address pr comments
farzonl 9cdfbc6
address Tex's PR comments
farzonl ee16a4b
address Tex's PR comments
farzonl e00e740
add CurrVS->NumPacked != VS->NumPacked check
farzonl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,38 +1,39 @@ | ||
//===- DirectXTargetTransformInfo.cpp - DirectX TTI ---------------*- C++ | ||
//-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "DirectXTargetTransformInfo.h" | ||
#include "llvm/IR/Intrinsics.h" | ||
#include "llvm/IR/IntrinsicsDirectX.h" | ||
|
||
using namespace llvm; | ||
|
||
bool DirectXTTIImpl::isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, | ||
unsigned ScalarOpdIdx) { | ||
switch (ID) { | ||
case Intrinsic::dx_wave_readlane: | ||
return ScalarOpdIdx == 1; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable( | ||
Intrinsic::ID ID) const { | ||
switch (ID) { | ||
case Intrinsic::dx_frac: | ||
case Intrinsic::dx_rsqrt: | ||
case Intrinsic::dx_wave_readlane: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
//===- DirectXTargetTransformInfo.cpp - DirectX TTI ---------------*- C++ | ||
//-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "DirectXTargetTransformInfo.h" | ||
#include "llvm/IR/Intrinsics.h" | ||
#include "llvm/IR/IntrinsicsDirectX.h" | ||
|
||
using namespace llvm; | ||
|
||
bool DirectXTTIImpl::isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, | ||
unsigned ScalarOpdIdx) { | ||
switch (ID) { | ||
case Intrinsic::dx_wave_readlane: | ||
return ScalarOpdIdx == 1; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable( | ||
Intrinsic::ID ID) const { | ||
switch (ID) { | ||
case Intrinsic::dx_frac: | ||
case Intrinsic::dx_rsqrt: | ||
case Intrinsic::dx_wave_readlane: | ||
case Intrinsic::dx_splitdouble: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -passes='function(scalarizer)' -S -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s | ||
|
||
define void @test_vector_double_split_void(<2 x double> noundef %d) { | ||
; CHECK-LABEL: define void @test_vector_double_split_void( | ||
; CHECK-SAME: <2 x double> noundef [[D:%.*]]) { | ||
; CHECK-NEXT: [[D_I0:%.*]] = extractelement <2 x double> [[D]], i64 0 | ||
; CHECK-NEXT: [[HLSL_ASUINT_I0:%.*]] = call { i32, i32 } @llvm.dx.splitdouble.i32(double [[D_I0]]) | ||
; CHECK-NEXT: [[D_I1:%.*]] = extractelement <2 x double> [[D]], i64 1 | ||
; CHECK-NEXT: [[HLSL_ASUINT_I1:%.*]] = call { i32, i32 } @llvm.dx.splitdouble.i32(double [[D_I1]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
%hlsl.asuint = call { <2 x i32>, <2 x i32> } @llvm.dx.splitdouble.v2i32(<2 x double> %d) | ||
tex3d marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ret void | ||
} | ||
|
||
define noundef <3 x i32> @test_vector_double_split(<3 x double> noundef %d) { | ||
; CHECK-LABEL: define noundef <3 x i32> @test_vector_double_split( | ||
; CHECK-SAME: <3 x double> noundef [[D:%.*]]) { | ||
; CHECK-NEXT: [[D_I0:%.*]] = extractelement <3 x double> [[D]], i64 0 | ||
; CHECK-NEXT: [[HLSL_ASUINT_I0:%.*]] = call { i32, i32 } @llvm.dx.splitdouble.i32(double [[D_I0]]) | ||
; CHECK-NEXT: [[D_I1:%.*]] = extractelement <3 x double> [[D]], i64 1 | ||
; CHECK-NEXT: [[HLSL_ASUINT_I1:%.*]] = call { i32, i32 } @llvm.dx.splitdouble.i32(double [[D_I1]]) | ||
; CHECK-NEXT: [[D_I2:%.*]] = extractelement <3 x double> [[D]], i64 2 | ||
; CHECK-NEXT: [[HLSL_ASUINT_I2:%.*]] = call { i32, i32 } @llvm.dx.splitdouble.i32(double [[D_I2]]) | ||
; CHECK-NEXT: [[DOTELEM0:%.*]] = extractvalue { i32, i32 } [[HLSL_ASUINT_I0]], 0 | ||
; CHECK-NEXT: [[DOTELEM01:%.*]] = extractvalue { i32, i32 } [[HLSL_ASUINT_I1]], 0 | ||
; CHECK-NEXT: [[DOTELEM02:%.*]] = extractvalue { i32, i32 } [[HLSL_ASUINT_I2]], 0 | ||
; CHECK-NEXT: [[DOTELEM1:%.*]] = extractvalue { i32, i32 } [[HLSL_ASUINT_I0]], 1 | ||
; CHECK-NEXT: [[DOTELEM13:%.*]] = extractvalue { i32, i32 } [[HLSL_ASUINT_I1]], 1 | ||
; CHECK-NEXT: [[DOTELEM14:%.*]] = extractvalue { i32, i32 } [[HLSL_ASUINT_I2]], 1 | ||
; CHECK-NEXT: [[DOTI0:%.*]] = add i32 [[DOTELEM0]], [[DOTELEM1]] | ||
; CHECK-NEXT: [[DOTI1:%.*]] = add i32 [[DOTELEM01]], [[DOTELEM13]] | ||
; CHECK-NEXT: [[DOTI2:%.*]] = add i32 [[DOTELEM02]], [[DOTELEM14]] | ||
; CHECK-NEXT: [[DOTUPTO015:%.*]] = insertelement <3 x i32> poison, i32 [[DOTI0]], i64 0 | ||
; CHECK-NEXT: [[DOTUPTO116:%.*]] = insertelement <3 x i32> [[DOTUPTO015]], i32 [[DOTI1]], i64 1 | ||
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <3 x i32> [[DOTUPTO116]], i32 [[DOTI2]], i64 2 | ||
; CHECK-NEXT: ret <3 x i32> [[TMP1]] | ||
; | ||
%hlsl.asuint = call { <3 x i32>, <3 x i32> } @llvm.dx.splitdouble.v3i32(<3 x double> %d) | ||
%1 = extractvalue { <3 x i32>, <3 x i32> } %hlsl.asuint, 0 | ||
%2 = extractvalue { <3 x i32>, <3 x i32> } %hlsl.asuint, 1 | ||
%3 = add <3 x i32> %1, %2 | ||
ret <3 x i32> %3 | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.