Commit Graph

92 Commits

Author SHA1 Message Date
cf2dc92ae5 Changes in code. 2025-09-01 13:03:23 +02:00
77cd23b537 Handle inline asm in vector alias
1. Improve vector alias optim to handle inline asm
2. Allow constant insert elements
2025-07-24 18:14:27 +02:00
420b632df9 Update IGC code format
Update IGC code format
2025-07-20 06:20:11 +02:00
72081c8424 Backout the previous change on dessa dumping.
As "PrintToConsole=1,DumpDeSSA=1" still generates dump files, revert the
previous change.
2024-04-23 01:34:43 +02:00
e5c2db0efc Using ptr as address payload's type
By design, address payload updating builtins does not create a new
address payload.  If the payload's type is int, not pointer, the
updating builtin would be like the following:
    (1) int addrP0 = createAddrPayload(...)
    (2) v = block2d_read (addrP0, ....)
    (3) int addrP1 = setBlockX(addrP0, ...)
In llvm IR, those addrP0 and addrP1 are different llvm values. And
it is legal for llvm to reorder instructions into { (1), (3), (2) },
which is incorrect as (2) should use the original addrP0, not the
updated one (addrP1).

For this reason, address payload should be of pointer type. With ptr
type, the above would be:
    (1) int* addrP0 = createAddrPayload(...)
    (2) v = block2d_read (addrP0, ....)
    (3) setBlockX(addrP0, ...)

The llvm cannot reorder them as there are dependences b/w (2) and (3)
via ptr arg.

This PR makes address payload's type to be pointer type (int*).
2024-04-09 07:47:03 +02:00
77f8e099a0 [Autobackout][FuncReg]Revert of change: a0caa5f28b
Using ptr as address payload's type

By design, address payload updating builtins does not create a new
address payload.  If the payload's type is int, not pointer, the
updating builtin would be like the following:
    (1) int addrP0 = createAddrPayload(...)
    (2) v = block2d_read (addrP0, ....)
    (3) int addrP1 = setBlockX(addrP0, ...)
In llvm IR, those addrP0 and addrP1 are different llvm values. And
it is legal for llvm to reorder instructions into { (1), (3), (2) },
which is incorrect as (2) should use the original addrP0, not the
updated one (addrP1).

For this reason, address payload should be of pointer type. With ptr
type, the above would be:
    (1) int* addrP0 = createAddrPayload(...)
    (2) v = block2d_read (addrP0, ....)
    (3) etBlockX(addrP0, ...)

The llvm cannot reorder them as there are dependences b/w (2) and (3).

This PR makes address payload's type to be pointer type (int*).
2024-04-08 22:27:49 +02:00
a0caa5f28b Using ptr as address payload's type
By design, address payload updating builtins does not create a new
address payload.  If the payload's type is int, not pointer, the
updating builtin would be like the following:
    (1) int addrP0 = createAddrPayload(...)
    (2) v = block2d_read (addrP0, ....)
    (3) int addrP1 = setBlockX(addrP0, ...)
In llvm IR, those addrP0 and addrP1 are different llvm values. And
it is legal for llvm to reorder instructions into { (1), (3), (2) },
which is incorrect as (2) should use the original addrP0, not the
updated one (addrP1).

For this reason, address payload should be of pointer type. With ptr
type, the above would be:
    (1) int* addrP0 = createAddrPayload(...)
    (2) v = block2d_read (addrP0, ....)
    (3) etBlockX(addrP0, ...)

The llvm cannot reorder them as there are dependences b/w (2) and (3).

This PR makes address payload's type to be pointer type (int*).
2024-04-08 07:01:21 +02:00
de184ad5aa Revise LSC2DBlock with address payload
1. address payload argument is of int, not int8. It is opaque.
      The reason for replacing int8 with int is to prevent IGC from
      scalarizing int8.
   2. Add Address payload copy in case it is more efficient than
      address payload create.
   3. Add updating builtins for base/width/height/pitch besides
      previously for blockx and blocky.
      The block shape is still only in create builtin as updating it
      needs to create a new address payload. For this, the shape will
      be in create builtin only.
2024-04-04 20:57:55 +02:00
c4432203bb New lsc2d block intrinsic
New lsc2d block intrinsic that uses address payload as a single
operand to block2d read/write/prefetch (their names have _ap_
in their name).

This is the 1st draft and subject to change.
2024-03-29 15:45:27 +01:00
5a04b7b724 Fix DeSSA dump
As dessa is dumped out under DumpDeSSA, don't use PrintToConsole to
control dumping of Dessa.
2024-03-28 19:03:44 +01:00
1cd6fa2a8a Minor fixes and refactors
Fix:
- uninitialized variables,
- potential memory leaks,
- invalid format strings passed `printf`.
Various small refactors and fixes.
2024-03-28 17:30:07 +01:00
67928124ff IGC and vISA refactors and small fixes
Fix issues found by Coverity.
2024-03-27 15:04:04 +01:00
5103715054 Make sure aliased vector have the same elt size
Vector alias uses a node value as the ID for a group of aliased values.
As two vectors of different sizes could be aliased to each other, a node
value may be different from the original one and thus has a different
element size than the original vector, which would cause incorrect offset
calculation.

This change fixes that by adding the type of the original base vector
into base vector struct.

In addition, the previous alignment checking code for subvector isn't
complete. This change re-implements it by get all coalesced values and
checks alignment for every one of them and selects the max of them.
2024-03-24 02:07:35 +01:00
1dd943811a Refactor subvec aliasing
1. Refactor subvec aliasing and apply it to limited cases.
  2. Add uniform checking to make sure subvec and vec have the same uniformity.
  3. Further add alignment checking to make sure subvec's mininum alignment
     requirement is guaranteed after becoming an alias to a larger vector.
     (Note: as simdsize isn't available when doing analysis, the minimum
     simdsize is used instead. This should be okay for dpas kernel as it
     uses the minimum simdsize.)
  4. This refactor also split funtionality into several sub functions for
     ease of testing. With VATemp=1, it handles vectors that are basically
     isolated; general cases are handled under VATemp=2.

     (VATemp >> 2) & 0x3 is to control extractelement aliasing, and
     (VATemp >> 4) & 0x3 is to control lifestart/end generation. Both
     will be turned on and tested later if needed.
2024-02-29 19:54:38 +01:00
4de2d84fb9 Remove redundant explicit return types in lambdas
Remove redundant explicit return types in lambdas
2024-01-11 13:44:28 +01:00
65bc729c5d prepare for supporting load combining
Add support in emit pass/dessa/wianalysis to support load combining that
uses struct for combining.

As load combining is off, this change has no functional issue.
2023-12-23 16:46:59 +01:00
3909793fea Do not dump extra files while running lit tests
This change is to not dump extra files during building processes.
2023-12-12 05:27:53 -05:00
89169e2dce Improve DeSSA for InsertValue
For aliasing InsertValue, allow number of indices up to 2.
This is mainly for layout struct that can have at most 2 indices.
2023-12-09 18:50:09 -05:00
98c4ff610a Fix insval aliasing in dessa
There is an issue (reported by Jakacki, Jakub) when merging two IVI chains.
Two chain cannot be merged if they have different uniformness. The code
does not check if two chains have the same uniformness.

This change adds that check. It also refactors the code a little bit.
2023-12-09 13:15:52 -05:00
cba322c077 Better alias handling
When grouping values of insertValue, only need to distinguish whether
both are uniform or both are not uniform. It is not necessary to distinguish
whether it is a global/group/thread uniform.
2023-07-06 06:15:34 +02:00
32847eca62 Better alias handling for layout struct
For layout struct, checking uniform/non-uniform is enough for aliasing
them.
2023-07-02 02:03:32 +02:00
487286e765 [Autobackout][FuncReg]Revert of change: b2f3260bbf
Better alias handling

When grouping values of insertValue and insertElement, only need to
distinguish whether both are uniform or both are not uniform. It is
not necessary to distinguish whether it is a global/group/thread
uniform.
2023-07-01 08:25:20 +02:00
b2f3260bbf Better alias handling
When grouping values of insertValue and insertElement, only need to
distinguish whether both are uniform or both are not uniform. It is
not necessary to distinguish whether it is a global/group/thread
uniform.
2023-06-30 08:22:00 +02:00
7bb07ba2d8 Alias uniform vec bitcast
If the two vectors of a bitcast (at least one is vector) are uniform,
make it alias to each other as their layout in GRF are the same.
2023-05-15 06:59:24 +02:00
e48f264274 Minor refactor
Make coalesing insertelement and alias work on a function, instead of
on a basic block, so that special handling for them can be done locally.

No functional change.
2023-05-14 21:34:28 +02:00
cd56325d13 Generic load/store combine pass
This is for combining LLVM LoadInst and StoreInst. It works even
those loads and stores have different element sizes (current memopt
does not handle load/store with different element sizes).

This is the first submit. It has majority of boilerplace code
implemented. It has store combining, the load combining will be
added later.
2023-04-19 01:43:53 +02:00
a130a4a6cb Fixed insVal coalescing
If two values from invertvalue chain have different uniformness,
they cannot be coalesced.  Make sure check their uniformness before
2023-03-28 00:46:00 +02:00
6d3cdf28bc uniform phi-copy in divergent CF 3rd
improve the fix by checking liveness
2023-03-15 06:02:56 +01:00
881acfa959 DeSSA uniform phi in divergent join 2nd
should isolate uniform phi  instead of isolating other sources
2023-03-11 04:34:23 +01:00
96b98747d5 DeSSA uniform phi in divergent join
detect overwritingr-moves when uniform phi in divergent join
2023-03-09 06:45:41 +01:00
b50e4b1f70 Minor fix to insertvalue
If dessa is off, coalescing insertvalue needs to check
if operand 0 is a single user. If it is, continue the
chain, otherwise has to stop.

This is to avoid coalescing the following case:
   a0 = insertvalue undef, s0, 0
   a1 = insertvalue a0, s1, 1
   a2 = insertvalue a1, s2, 2

   b1 = insertvalue a0, x1, 1
   b2 = insertvalue b1, x2, 2

      = foo(a2)
      = foo(b2)

   {a1, a2} can be coalesced as well as {b1, b2}; but
   {a1, a2} cannot coalesce with {b1, b2}.
2023-02-15 07:13:19 +01:00
6e157d8086 Turn off DeSSA if EnableDeSSA is 0
Previously, DeSSA always run, even though EnableDeSSA is 0.

This change turns off DeSSA if EnableDeSSA is 0.
2023-02-15 00:28:12 +01:00
42e36467e6 Better dessa for insertvalue
For any insertvalue inst chain, make them aliases to each other.
Also, if two insertvalue chain define the disjoint struct fields,
they are combined and set to alias each other.
2023-02-11 00:56:43 +01:00
5c1d54ac8b dessa support of insertValue
This is to let dessa to support insertValue to struct. This
change is an initial effort and is experimental in nature.

The reasonale is to coalescing multiple load/store into a struct and
have an efficient and single load/store instruction for them.
2023-01-17 22:54:09 +01:00
ca6eb9c0c4 Retire key EnableDeSSAAlias
As EnableDeSSAAlias has been stable for a while, the key is no longer needed.

This change deletes the key EnableDeSSAAlias. With this, this DeSSAAlias is
always on and cannot be disabled. This simplifies the dessa as the code for
dessaalias=off can be safely deleted.
2023-01-11 18:08:54 +01:00
6e359a7e64 change comments
Clean up comments for dessa
2023-01-11 00:45:48 +01:00
bd94b54982 Simplify key EnableDeSSAAlias
EnableDeSSAAlias is of int originally during development of coalescing
alias (bitcast, etc) to have a finer control. It is stable now and no
longer need to be of int.

This submit has the following changes:
   1. Changes EnableDeSSAAlias to bool;
   2. Change DisableDeSSA to EnableDeSSA
   3. Guard the use of EnableDeSSAAlias with EnableDeSSA as EnableDeSSAAlias
      is used only if DeSSA is on.

No function change expected from this submit.
2022-12-16 02:35:07 +01:00
8ca849ab3d DPAS intrinsics
Enables certain DPAS intrinsics
2022-02-13 23:07:21 +01:00
18e51ddee8 KW fix for uninitialized variables
KW fix for uninitialized variables
2021-10-15 01:40:47 +02:00
9cf1275a3a Minor fixes
Minor fixes
2021-09-30 07:54:35 +02:00
8c23cc470c [Autobackout][FuncReg]Revert of change: f1fed8f34f
Minor fixes

Fixed newlines at the end of file
2021-09-20 22:19:03 +02:00
f1fed8f34f Minor fixes
Fixed newlines at the end of file
2021-09-12 20:42:22 +02:00
661333ec59 Part fix for buildbreak on LLVM12 2021-08-24 12:24:54 +02:00
6fc7704a62 update copyright headers in IGC Compiler 2021-05-06 22:52:55 +02:00
32944e60e9 [Autobackout][FuncReg]Revert of change: 1c28c742da
Fix build with LLVM 12

Removed TargetLibraryInfo.h include from AddressSpaceAliasAnalysis.cpp
as this was causing treat-warning-as-error buildbreak,
Added casts to fix warnings,
Replaced ConstantPropagation and IPConstantPropagation passes with
IPSCCP passes,
reasoning here:
https://lists.llvm.org/pipermail/llvm-dev/2020-July/143788.html

Original pull-request:
intel/intel-graphics-compiler#171

Signed-off-by: Zoltán Böszörményi zboszor@gmail.com
Co-authored-by: Pawel Szymichowski pawel.szymichowski@intel.com

Co-authored-by: Zoltán Böszörményi zboszor@pr.hu
2021-04-29 18:18:35 +02:00
1c28c742da Fix build with LLVM 12
Removed TargetLibraryInfo.h include from AddressSpaceAliasAnalysis.cpp
as this was causing treat-warning-as-error buildbreak,
Added casts to fix warnings,
Replaced ConstantPropagation and IPConstantPropagation passes with
IPSCCP passes,
reasoning here:
https://lists.llvm.org/pipermail/llvm-dev/2020-July/143788.html

Original pull-request:
intel/intel-graphics-compiler#171

Signed-off-by: Zoltán Böszörményi zboszor@gmail.com
Co-authored-by: Pawel Szymichowski pawel.szymichowski@intel.com

Co-authored-by: Zoltán Böszörményi zboszor@pr.hu
2021-04-26 16:00:24 +02:00
bcda9e4e7b [Autobackout][FuncReg]Revert of change: 4bc6b443a5
Fix build with LLVM 12

Removed TargetLibraryInfo.h include from AddressSpaceAliasAnalysis.cpp as this was causing treat-warning-as-error buildbreak,
Added casts to fix warnings,
Replaced ConstantPropagation and IPConstantPropagation passes with IPSCCP passes,
reasoning here: https://lists.llvm.org/pipermail/llvm-dev/2020-July/143788.html

Original pull-request: https://github.com/intel/intel-graphics-compiler/pull/171

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Co-authored-by: Pawel Szymichowski <pawel.szymichowski@intel.com>
2021-04-23 04:03:32 +02:00
4bc6b443a5 Fix build with LLVM 12
Removed TargetLibraryInfo.h include from AddressSpaceAliasAnalysis.cpp as this was causing treat-warning-as-error buildbreak,
Added casts to fix warnings,
Replaced ConstantPropagation and IPConstantPropagation passes with IPSCCP passes,
reasoning here: https://lists.llvm.org/pipermail/llvm-dev/2020-July/143788.html

Original pull-request: https://github.com/intel/intel-graphics-compiler/pull/171

Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
Co-authored-by: Pawel Szymichowski <pawel.szymichowski@intel.com>
2021-04-21 16:11:37 +02:00
3b18b29c26 Fix a warning treated as error 2021-03-20 06:15:53 +01:00
2e3ddd6361 updated copyright headers in IGC Compiler 2021-02-21 22:43:53 +01:00