|
9 | 9 | #ifndef AMDGPU |
10 | 10 | #define AMDGPU |
11 | 11 |
|
| 12 | +include "mlir/IR/EnumAttr.td" |
| 13 | +include "mlir/IR/OpBase.td" |
| 14 | +include "mlir/IR/Properties.td" |
| 15 | +include "mlir/Interfaces/InferIntRangeInterface.td" |
12 | 16 | include "mlir/Interfaces/InferTypeOpInterface.td" |
13 | 17 | include "mlir/Interfaces/SideEffectInterfaces.td" |
14 | 18 | include "mlir/Interfaces/ViewLikeInterface.td" |
15 | | -include "mlir/IR/EnumAttr.td" |
16 | | -include "mlir/IR/Properties.td" |
17 | | -include "mlir/IR/OpBase.td" |
18 | 19 |
|
19 | 20 | def AMDGPU_Dialect : Dialect { |
20 | 21 | let name = "amdgpu"; |
@@ -635,6 +636,37 @@ def AMDGPU_DPPOp : AMDGPU_Op<"dpp", |
635 | 636 | let hasVerifier = 1; |
636 | 637 | } |
637 | 638 |
|
| 639 | +def AMDGPU_AssumeSubgroupUniformOp : AMDGPU_Op<"assume_subgroup_uniform", |
| 640 | + [NoMemoryEffect, AllTypesMatch<["result", "src"]>, |
| 641 | + DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>, |
| 642 | + DeclareOpInterfaceMethods<ConditionallySpeculatable, ["getSpeculatability"]>] # |
| 643 | + ElementwiseMappable.traits>, |
| 644 | + Arguments<(ins AnyType:$src, |
| 645 | + DefaultValuedAttr<UnitAttr, "false">:$all_lanes)> { |
| 646 | + let summary = "Assumes value is unform across the lanes in subgroup"; |
| 647 | + let description = [{ |
| 648 | + This op is a compiler hint to help backend put values into scalar registers. |
| 649 | + |
| 650 | + If `src` value is uniform across all the active subgroup lanes it is |
| 651 | + returned unchanged, otherwise result is poison. |
| 652 | + |
| 653 | + If `all_lanes` is set, the value is assumed to be uniform across all the |
| 654 | + subgroup lanes, this can allow to speculate it out of control flow, which |
| 655 | + may change the current active lanes, i.e: |
| 656 | + ``` |
| 657 | + // %value must be uniform at this point |
| 658 | + %value = ... |
| 659 | + scf.if lane_id < 13 { |
| 660 | + %uniform = amdgpu.assume_subgroup_uniform all_lanes %value |
| 661 | + } |
| 662 | + ``` |
| 663 | + }]; |
| 664 | + let results = (outs AnyType:$result); |
| 665 | + let assemblyFormat = [{ |
| 666 | + (`all_lanes` $all_lanes^)? $src attr-dict `:` type($result) |
| 667 | + }]; |
| 668 | +} |
| 669 | + |
638 | 670 | def AMDGPU_SwizzleBitModeOp : AMDGPU_Op<"swizzle_bitmode", |
639 | 671 | [Pure, AllTypesMatch<["result", "src"]>]>, |
640 | 672 | Arguments<(ins AnyIntegerOrFloatOr1DVector:$src, |
|
0 commit comments