302 Commits

Author SHA1 Message Date
Kaitlin Peng
0bb1af478a
[DirectX] Add GlobalDCE pass after finalize linkage pass in DirectX backend (#151071)
Fixes #139023.

This PR essentially removes unused global variables:
- Restores the `GlobalDCE` Legacy pass and adds it to the DirectX
backend after the finalize linkage pass
- Converts external global variables with no usage to internal linkage
in the finalize linkage pass
  - (so they can be removed by `GlobalDCE`)
- Makes the `dxil-finalize-linkage` pass usable using the new pass
manager flag syntax
- Adds tests to `finalize_linkage.ll` that make sure unused global
variables are removed
- Adds a use for variable `@CBV` in `opaque-value_as_metadata.ll` so it
isn't removed
- Changes the `scalar-data.ll` run command to avoid removing its global
variables

---------

Co-authored-by: Farzon Lotfi <farzonlotfi@microsoft.com>
2025-08-15 10:45:34 -07:00
joaosaffran
d56fa96524
[DirectX] Add Range Overlap validation (#152229)
As part of the Root Signature Spec, we need to validate if Root
Signatures are not defining overlapping ranges.
Closes: https://github.com/llvm/llvm-project/issues/126645

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Co-authored-by: Joao Saffran <jderezende@microsoft.com>
2025-08-14 18:40:11 -04:00
Farzon Lotfi
544562ebc2
[DirectX] Remove lifetime intrinsics and run Dead Store Elimination (#152636)
fixes #151764

This fix has two parts first we track all lifetime intrinsics and if
they are users of an alloca of a target extention like dx.RawBuffer then
we eliminate those memory intrinsics when we visit the alloca.

We do step one to allow us to use the Dead Store Elimination Pass. This
removes the alloca and simplifies the use of the target extention back
to using just the global. That keeps things in a form the
DXILBitcodeWriter is expecting.

Obviously to pull this off we needed to bring back the legacy pass
manager plumbing for the DSE pass and hook it up into the DirectX
backend.

The net impact of this change is that DML shader pass rate went from
89.72% (4268 successful compilations) to 90.98% (4328 successful
compilations).
2025-08-12 12:42:08 -04:00
Helena Kotas
5165a6c197
[HLSL] Update DXIL resource metadata code to support resource arrays (#152254)
Closes #145422
2025-08-11 14:55:54 -07:00
Kaitlin Peng
cbc8f650ea
[HLSL][DirectX] Fix dot2add DXIL operation to use float overload (#152781)
Fixes #152585.

The `dot2add` DXILOpFunction should be `dx.op.dot2AddHalf.f32` (i.e. it
has [a single overload that's a
float](https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py#L3960),
rather than no overloads). It was also being defined for too low of a
DXIL version - [dxc says
SM6.4](https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py#L740).
2025-08-11 13:03:24 -07:00
Helena Kotas
fb1035cfb4
[DirectX] Fix resource binding analysis incorrectly removing duplicates (#152253)
The resource binding analysis was incorrectly reducing the size of the
`Bindings` vector by one element after sorting and de-duplication. This
led to an inaccurate setting of the `HasOverlappingBinding` flag in the
`DXILResourceBindingInfo` analysis, as the truncated vector no longer
reflected the true binding state.

This update corrects the shrink logic and introduces an `assert` in the
`DXILPostOptimizationValidation` pass. The assertion will trigger if
`HasOverlappingBinding` is set but no corresponding error is detected,
helping catch future inconsistencies.

The bug surfaced when the `srv_metadata.hlsl` and `uav_metadata.hlsl`
tests were updated to include unbounded resource arrays as part of
https://github.com/llvm/llvm-project/issues/145422. These updated test
files are included in this PR, as they would cause the new assertion to
fire if the original issue remained unresolved.

Depends on #152250
2025-08-11 10:53:00 -07:00
Deric C.
e13cb3e299
[DirectX] Update lifetime legalization to account for the removed size argument (#152791)
Fixes #152754 

- Fixes the ArgOperand index in `DXILOpLowering.cpp` used to obtain the
pointer operand of a lifetime intrinsic.
- Updates the tests
`llvm/test/CodeGen/DirectX/legalize-lifetimes-valver-1.5.ll`,
`llvm/test/CodeGen/DirectX/legalize-lifetimes-valver-1.6.ll`,
`llvm/test/CodeGen/DirectX/ShaderFlags/lifetimes-noint64op.ll`, and
`llvm/test/tools/dxil-dis/lifetimes.ll` to use the new size-less
lifetime intrinsic
- Removes lifetime intrinsics from the test
`llvm/test/CodeGen/DirectX/legalize-memset.ll` to be consistent with the
corresponding memcpy test which does not have lifetime intrinsics.
(Removal of lifetime intrinsics from tests like this was suggested here
in the past:
https://github.com/llvm/llvm-project/pull/139173#discussion_r2091778868)
- Rewrites the lifetime legalization functions in the EmbedDXILPass to
re-add the explicit size argument for DXIL
2025-08-08 14:32:27 -07:00
Helena Kotas
f7c6c7ce36
[DirectX] Overlapping binding detection - check register space first (#152250)
The code that checks for overlapping binding did not compare register space when one of the bindings was for an unbounded resource array, leading to false errors. This change fixes it.
2025-08-07 10:48:47 -07:00
Kaitlin Peng
bd741975bc
Scalarize vector mad operations for integer types (#152228)
Fixes #152220.

- Adds `dx_imad` and `dx_umad` to
`isTargetIntrinsicTriviallyScalarizable`
- Adds tests that confirm the intrinsic is now scalarizing
2025-08-07 09:34:42 -07:00
Farzon Lotfi
04672e20d4
[DirectX] ForwardHandle needs to check if globals were stored on allocas (#151751)
fixes #140819

SROA pass is making it so that some globals get loaded into stack
allocations. This means we find an alloca where we use to expect a load
and now need to walk an alloca -> store -> maybe load chain before we
find the global. Doing so fixes All but two instances of #137715 And
fixes every instance of `Load of "8.sroa.0" is not a global resource
handle we are currently seeing in the DML shaders.
2025-08-06 21:14:35 -04:00
joaosaffran
b2e5303292
[DirectX] Error handling improve in root signature metadata Parser (#149232)
This PR addresses
https://github.com/llvm/llvm-project/pull/144465#issuecomment-3063422828.
Using `joinErrors` and `llvm:Error` instead of boolean values.

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
Co-authored-by: Joao Saffran <{ID}+{username}@users.noreply.github.com>
2025-07-31 22:59:02 -04:00
Helena Kotas
f169af3ba7
[HLSL] Fix detection of overlapping binding with unbounded array (#150547)
Fixes #150534
2025-07-25 09:41:20 -07:00
Deric C.
4ae2678372
[DirectX] Add support for vector type checking in DXIL Shader Flag Analysis (#150532)
Fixes #150482 by replacing all `Instruction.getType()` in
DXILShaderFlags.cpp with `Instruction.getType()->getScalarType()` to
account for vectors types as suggested by @bogner
2025-07-24 17:09:34 -07:00
Deric C.
e178e82c63
[DirectX] Do not flatten GEP chains for unsupported types (#150484)
Fixes #150463 by not processing GEPs for unsupported types such as
structs in the DXILFlattenArrays pass.
2025-07-24 13:36:36 -07:00
Farzon Lotfi
c73c19c60e
[DirectX] Support ConstExpr GEPs (#150082)
- Fixes #150050
- Address the issue of many nested geps
- Check for ConstantExpr GEP if we see it check if it needs a global
replacement with a new type. Create the new constExpr Gep and set the
pointer operand to it. Finally cleanup and remove the old nested geps.
2025-07-23 16:38:14 -04:00
Deric C.
c3c72c1de9
[DirectX] Legalize llvm.lifetime.* intrinsics in EmbedDXILPass (#150100)
Fixes #147395

This PR:
- Excludes lifetime intrinsics from the Int64Ops shader flags analysis
to match DXC behavior and pass DXIL validation.
- Performs legalization of `llvm.lifetime.*` intrinsics in the
EmbedDXILPass just before invoking the DXILBitcodeWriter.
- After invoking the DXILBitcodeWriter, all lifetime intrinsics and
associated bitcasts are removed from the module to keep the Module
Verifier happy. This is fine since lifetime intrinsics are not needed by
any passes after the EmbedDXILPass.
2025-07-22 17:08:05 -07:00
Deric C.
0c14f0e891
[Scalarizer] Use correct key for ExtractValueInst gather (#149855)
Fixes #149345

Effectively no-op pairs of insertelement-extractelement instructions
were being created due to the ExtractValueInst visitor in the Scalarizer
storing its scalarized result into the Scattered map using an incorrect
key (specifically the type used in the key).
This PR fixes this issue.
2025-07-21 17:12:15 -07:00
Deric C.
8f9ed78874
Revert "[DirectX] Legalize lifetime intrinsics for DXIL" (#149883)
Reverts llvm/llvm-project#148003 to fix a DirectX backend build breakage
due to #149310
2025-07-21 12:34:50 -07:00
Deric C.
c4f3bc91c0
Revert "Revert "[DirectX] Lower llvm.lifetime.* intrinsics to stores when DXIL version is lower than 1.6 (#147432)"" (#149882)
Reverts llvm/llvm-project#149874

Reverted the wrong PR by mistake.
2025-07-21 12:29:22 -07:00
Deric C.
509af524e3
Revert "[DirectX] Lower llvm.lifetime.* intrinsics to stores when DXIL version is lower than 1.6 (#147432)" (#149874)
This PR reverts commit d47c126fbf7915c01ea112ae372fe8835df4379f
(corresponding to PR #147432) to fix a build failure caused by #149310
2025-07-21 12:10:36 -07:00
Deric C.
fae8df2b82
[DirectX] Fix GEP flattening with 0-indexed GEPs on global variables (#149211)
Fixes #149179 

The issue is that `Builder.CreateGEP` does not return a GEP Instruction
or GEP ContantExpr when the pointer operand is a global variable and all
indices are constant zeroes.

This PR ensures that a GEP instruction is created if `Builder.CreateGEP`
did not return a GEP.
2025-07-17 14:51:53 -07:00
Deric C.
689e95817e
[DirectX] Add a GEP to scalar load/store on globals and remove incorrect assertion (#149191)
Fixes #149180

This PR removes an assertion that triggered on valid IR. It has been
replaced with an if statement that returns early if the conditions are
not correct.

This PR also adds GEPs to scalar loads and stores from/to global
variables.
2025-07-17 14:46:45 -07:00
Deric C.
a9021e5373
Emit array GEPs in memcpy/memset legalization (#148886)
Fixes #148089
2025-07-15 11:35:20 -07:00
Deric C.
09f7cab9a3
[DirectX] Add a GEP to loads and stores on array allocas (#148059)
Fixes #147114 by inserting a GEP between any direct loads and stores on
an alloca.
2025-07-15 10:40:52 -07:00
Deric C.
27b3b4a665
[DirectX] Move the scalarizer pass to before dxil-flatten-arrays (#146800)
Fixes #145924 and #140416
Depends on #146173 being merged first.

This PR moves the scalarizer pass to immediately before the
dxil-flatten-arrays pass to allow the dxil-flatten-arrays pass to turn
scalar GEPs (including i8 GEPs) into flattened array GEPs where
applicable.

A number of LLVM DirectX CodeGen tests have been edited to remove scalar
GEPs and also correct previously uncaught incorrectly-transformed GEPs.

No more validation errors of the form `Access to out-of-bounds memory is
disallowed` or `TGSM pointers must originate from an unambiguous TGSM
global variable` appear anymore after this PR when compiling DML
shaders.
2025-07-14 18:13:42 -07:00
Deric C.
352215c6eb
[DirectX] Simplify and correct the flattening of GEPs in DXILFlattenArrays (#146173)
In tandem with #146800, this PR fixes #145370

This PR simplifies the logic for collapsing GEP chains and replacing
GEPs to multidimensional arrays with GEPs to flattened arrays. This
implementation avoids unnecessary recursion and more robustly computes
the index to the flattened array by using the GEPOperator's
collectOffset function, which has the side effect of allowing "i8 GEPs"
and other types of GEPs to be handled naturally in the flattening /
collapsing of GEP chains.

Furthermore, a handful of LLVM DirectX CodeGen tests have been edited to
fix incorrect GEP offsets, mismatched types (e.g., loading i32s from a
an array of floats), and typos.
2025-07-14 16:39:01 -07:00
Deric C.
fee27b3337
[DirectX] Legalize lifetime intrinsics for DXIL (#148003)
Fixes #147395

This PR legalizes lifetime intrinsics for DXIL by
- Adding a bitcast for the lifetime intrinsics' pointer operand in
dxil-prepare to ensure it gets cast to an `i8*` when written to DXIL
- Removing the memory attribute from lifetime intrinsics in dxil-prepare
to match DXIL
- Making the DXIL bitcode writer write the base/demangled name of
lifetime intrinsics to the symbol table
- Making lifetime intrinsics an exception to Int64Ops shader flag
analysis (otherwise we get `error: Flags must match usage.` from the
validator)
2025-07-11 12:26:53 -07:00
Finn Plummer
420e2f584d
[DirectX] Add missing verifications during validate of DXILRootSignature (#147111)
This pr resolves some discrepancies in verification during `validate` in
`DXILRootSignature.cpp`.

Note: we don't add a backend test for version 1.0 flag values because it
treats the struct as though there is no flags value. However, this will
be used when we use the verifications in the frontend.

- Updates `verifyDescriptorFlag` to check for valid flags based on
version, as reflected [here](https://github.com/llvm/wg-hlsl/pull/297)
- Add test to demonstrate updated flag verifications
- Adds `verifyNumDescriptors` to the validation of `DescriptorRange`s
- Add a test to demonstrate `numDescriptors` verification
- Updates a number of tests that mistakenly had an invalid
`numDescriptors` specified

Resolves: https://github.com/llvm/llvm-project/issues/147107
2025-07-09 12:02:02 -07:00
Deric C.
d47c126fbf
[DirectX] Lower llvm.lifetime.* intrinsics to stores when DXIL version is lower than 1.6 (#147432)
Fixes #147394

References DXC for the implementation logic:

d751c827ed/lib/HLSL/DxilPreparePasses.cpp (L693-L699)

If DXIL Version < 1.6 then replace lifetime intrinsics with stores

- For validator version >= 1.6, store an undef
- For validator version < 1.6, store zeros

else keep the lifetime intrinsics in the DXIL.

After this PR, the number of DML shaders failing validation due to
#146974 is reduced from 157 to 50.
2025-07-08 14:45:14 -07:00
Sarah Spall
5e87a712f9
[DirectX] Add support for Raw Buffer Loads and Stores for scalars and vectors of doubles and i64s in SM6.2 and earlier (#146627)
For SM6.2 and earlier, Raw buffer Loads and Stores can't handle 64 bit
types. This PR expands Raw Buffer Loads and Stores for 64 bit types
double and int64_t. This Adds to the work done in #139996 and #145047 .
Raw Buffer Loads and Stores allow for 64 bit type vectors of size 3 and
4, and the code is modified to allow for that.
Closes #144747
2025-07-07 16:42:32 -07:00
Kaitlin Peng
dc8e89b2b3
[DirectX] Convert private global variables to internal linkage during Finalize Linkage pass (#146406)
Fixes #140420. The switch.table.* validation errors were caused by DXIL
not supporting private global variables. Converting them to internal
linkage fixes the bug.

May need more discussion on the preserved analyses/a follow-up PR that
fixes what this pass says it preserves.
2025-07-07 10:50:43 -07:00
Deric C.
12409a18f6
[DirectX] Implement memcpy in DXIL CBuffer Access pass (#144436)
Fixes #141840

This PR implements support for the `memcpy` intrinsic in the DXIL
CBuffer Access pass with the following restrictions:

- The CBuffer Access must be the `src` operand of `memcpy` and must be
direct (i.e., not a GEP)
- The type of the CBuffer Access must be of an Array Type

These restrictions greatly simplify the implementation of `memcpy` yet
still covers the known uses in DML shaders.

Furthermore, to prevent errors like #141840 from occurring silently
again, this PR adds error reporting for unsupported users of globals in
the DXIL CBuffer Access pass.
2025-06-30 16:32:43 -07:00
joaosaffran
171aa34e43
[DirectX] Add static sampler support to root signature (#143422)
Implements static samplers parsing from root signature metadata
representation. This is required to support Root Signatures in HLSL.
Closes: #[126641](https://github.com/llvm/llvm-project/issues/126641)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-06-27 14:30:48 -07:00
Farzon Lotfi
5dbd8772fe
[DirectX] add support for i64 buffer load/stores (#145047)
fixes #140321

Specifically it fixes ` error: Cannot create BufferLoad operation:
Invalid overload type`
https://hlsl.godbolt.org/z/dTq4q7o58
but no new DML shaders are building. This change now exposes #144747.

The change does two things it adds i64 support for intrinsic expansion
for the `dx_resource_load_typedbuffer`, and
`dx_resource_store_typedbuffer` intrinsics.

It also lets loaded typedbuffers crash more gracefully because of ` auto
*EVI = cast<ExtractValueInst>(U);` is now a `dyn_cast` and
`llvm_unreachable`.
2025-06-27 14:11:56 -04:00
Farzon Lotfi
778b6a21ec
[DirectX] Allow vector Allocas to be transformed into arrays (#145972)
fixes #145782

This change modifies `isArrayOfVectors` into `isVectorOrArrayOfVectors`.
The previous implementation did not support vector to array
transformations. Further it was too simplistic and didn't assume allocas
would create multidimensional arrays.
2025-06-27 13:12:47 -04:00
Farzon Lotfi
38aec4f1f4
[DirectX] Limit GEP transformations to Arrays (#145758)
fixes #145408

Before we see the GEP we already have transformed Allocas that get
passed the `isArrayOfVectors`.
The bug is because we are trying to transform a gep for struct of arrays
when we should only be transforming arrays.

The problem with our `visitGetElementPtrInst` is that it was doing
transformations for all allocas when it should be limiting it to the
alloca of array cases. Technically we would have liked to make sure it
was an array of vectors cases but by the time we see the GEP the type
has been changed by replace all uses. There should not be a problem with
looking at all Arrays since DXILDataScalarization does not change any
indicies.
2025-06-25 17:17:52 -04:00
Finn Plummer
a8ef75e758
[DirectX] Strip dx.rootsignatures metadata during dxil-prepare (#145746)
The `dx.rootsignatures` metadata is not recognized in DXIL, so failure
to remove this will cause validation errors.

This metadata is parsed (within `RootSignatureAnalysisWrapper`) into its
binary format. As such, once it has been used to construct the binary
form, it can be safely discarded without loss of information.

This pr ensures that the dxil prepare pass will depend and preserve on
the root signature analysis so that it runs before the metadata is
removed.

- Update `DXILPrepare.cpp` to preserve and depend on
`RootSignatureAnalysisWrapper`
- Update test to demonstrate order is correct
- Provide test-case to demonstrate the metadata is removed

Resolves https://github.com/llvm/llvm-project/issues/145437.

----------

Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-06-25 14:06:46 -07:00
Ashley Coleman
21423c7fdc
[DirectX] Make firstbithigh intrinsic use first arg as overload type (#145401)
Sibling to https://github.com/llvm/llvm-project/pull/145350 part of
https://github.com/llvm/llvm-project/issues/144966

firstbituhigh and firstbitshigh should use the first arg for overloads
instead of the return type since the return is always i32
2025-06-24 12:00:21 -06:00
Tex Riddell
509fb931b4
Fix min_vec_size.ll test for changes in vector-combine (#145392)
Running the `vector-combine` pass on this test now produces a single
shuffle on a loaded `<1 x float>` instead of an insert into a `<2 x
float>` followed by a shuffle.

This test change matches changes in other tests in PR #144690, which
introduced the optimization.
2025-06-23 14:53:57 -07:00
Farzon Lotfi
0f173a0f9a
[DirectX] make firstbitlow intrinsic use first argument instead of return for overload type (#145350)
fixes #144966
Easy fix just add `dx_firstbitlow` to
`DirectXTTIImpl::isTargetIntrinsicWithOverloadTypeAtArg`
2025-06-23 14:04:06 -04:00
Justin Bogner
6b9fe9e0bc
[HLSL] Emit a version in the dx.rootsignatures metadata (#145113)
In #144957 the backend was updated to expect a version in the metadata,
but since the frontend wasn't updated this breaks compilation. This is a
somewhat temporary fix to that until #144813 lands.
2025-06-20 16:21:47 -07:00
Farzon Lotfi
2a4207e732
[DirectX] Don't limit visitGetElementPtrInst to global ptrs (#144959)
fixes #144608
- there is a getPointerOperandIndex function so we don't need to iterate
the operands trying to find the pointer. This resulted in a small
cleanup to visitStoreInst and visitLoadInst.

- The meat of this change was in visitGetElementPtrInst to account for
allocas and not bail when we don't find a global.
2025-06-20 15:23:20 -04:00
joaosaffran
b5d5708128
[HLSL] Add descriptor table metadata parsing (#142492)
Implements descriptor table parsing from root signature metadata. This
is required to support root signatures in hlsl.
Closes: #[126640](https://github.com/llvm/llvm-project/issues/126640)

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-06-20 12:12:02 -07:00
Deric C.
3f42c6bddd
[DirectX] Scalarize extractelement and insertelement with dynamic indices (#141676)
Fixes #141136

- Implement `visitExtractElementInst` and `visitInsertElementInst` in
`DXILDataScalarizerVisitor` to scalarize `extractelement` and
`insertelement` instructions whose index operand is not a `ConstantInt`
by converting the vector to an array and then loading from the array
- Rename the `replaceVectorWithArray` helper function to
`equivalentArrayTypeFromVector`, relocate the function toward the top of
the file, and remove the unused `Ctx` parameter
2025-06-20 11:20:30 -07:00
joaosaffran
fa7646008e
[DirectX] Add Root Signature Version Support and Update Test IR Format (#144957)
Updates the Root Signature metadata parser to extract version
information. This requirement was added after the initial parser
implementation.

---------

Co-authored-by: joaosaffran <joao.saffran@microsoft.com>
2025-06-19 17:39:48 -07:00
Joshua Batista
b59d4cf054
[Reland] Adjust bit cast instruction filter for DXIL Prepare pass (#143783)
Relands https://github.com/llvm/llvm-project/pull/142678, with a new
change to remove an unnecessary gep argument, after a revert was needed
due to unforeseen bugs.
Fixes https://github.com/llvm/llvm-project/issues/139013
2025-06-17 11:46:12 -07:00
Steven Perron
a027eb4472
[HLSL] Use hidden visibility for external linkage. (#140292)
Implements

https://github.com/llvm/wg-hlsl/blob/main/proposals/0026-symbol-visibility.md.

The change is to stop using the `hlsl.export` attribute. Instead,
symbols with "program linkage" in HLSL will have export linkage with
default visibility, and symbols with "external linkage" in HLSL will
have export linkage with hidden visibility.
2025-06-16 16:44:55 -04:00
Farzon Lotfi
fc6aac72cc
[DirectX] Fix bug where Flatten arrays was only using last index (#144146)
fixes #142836

We added a function called `collectIndicesAndDimsFromGEP` which builds
the Indicies and Dims up for the recursive case and the base case.
really to solve #142836 we didn't need to add it to the recursive case.
The recursive cases exists for gep chains which are ussually two
indicies per gep ie ptr index and array index. adding
collectIndicesAndDimsFromGEP to the recursive cases means we can now do
some mixed mode indexing say we get a case where its not the ussual 2
indicies but instead 3 we can now treat those last two indicies as part
of the computation for the flat array index.
2025-06-16 11:53:55 -04:00
Farzon Lotfi
882b58a90a
[DirectX] Reland #142853 with Circular GEP fixes (#143747)
This change relands  https://github.com/llvm/llvm-project/pull/142853
It fixes the circular reference issue we were seeing in GEPs
ex `%.flat = getelementptr inbounds [16 x i32], ptr %.flat, i32 0, i32
15`
2025-06-12 12:12:01 -04:00
Farzon Lotfi
76c4ba6a1d
Revert "[DirectX] Array GEPs need two indices (#142853)" and "Adjust bit cast instruction filter for DXIL Prepare pass (#142678)" (#143043)
- This reverts commit 9ab4c16042a38d5b80084afff52699e246ca9ea8.
- This reverts commit 1d6e8ec17d547a5f8a0db700dc107a2cd7a321e1.

Noticed a really weird behavior where release and debug builds have
different codegen for loads with geps after this PR. This is going to
take a minute to debug and figure out why so revert seems to make the
most sense.

```diff
diff --git a/llvm/test/CodeGen/DirectX/flatten-array.ll b/llvm/test/CodeGen/DirectX/flatten-array.ll
index 47d7b50cf018..efa9efeff13a 100644
--- a/llvm/test/CodeGen/DirectX/flatten-array.ll
+++ b/llvm/test/CodeGen/DirectX/flatten-array.ll
@@ -123,7 +123,8 @@ define void @gep_4d_test ()  {
@b = internal global [2 x [3 x [4 x i32]]] zeroinitializer, align 16
define void @global_gep_load() {
-  ; CHECK: load i32, ptr getelementptr inbounds ([24 x i32], ptr @a.1dim, i32 0, i32 6), align 4
+  ; CHECK: %1 = getelementptr inbounds [24 x i32], ptr @a.1dim, i32 0, i32 6
+  ; CHECK-NEXT: %2 = load i32, ptr %1, align 4
   ; CHECK-NEXT:    ret void
   %1 = getelementptr inbounds [2 x [3 x [4 x i32]]], [2 x [3 x [4 x i32]]]* @a, i32 0, i32 0
   %2 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i32 0, i32 1
@@ -176,7 +177,8 @@ define void @global_incomplete_gep_chain(i32 %row, i32 %col) {
}
define void @global_gep_store() {
-  ; CHECK: store i32 1, ptr getelementptr inbounds ([24 x i32], ptr @b.1dim, i32 0, i32 13), align 4
+  ; CHECK: %1 = getelementptr inbounds [24 x i32], ptr @b.1dim, i32 0, i32 13
+  ; CHECK-NEXT: store i32 1, ptr %1, align 4
   ; CHECK-NEXT:    ret void
```
2025-06-05 20:41:37 -04:00