This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow memref.cast to change the signed/unsigned/signless element type
AbandonedPublic

Authored by ezhulenev on Sep 14 2022, 7:21 PM.

Diff Detail

Event Timeline

ezhulenev created this revision.Sep 14 2022, 7:21 PM
ezhulenev requested review of this revision.Sep 14 2022, 7:21 PM
ezhulenev updated this revision to Diff 460289.Sep 14 2022, 7:42 PM

Revert accidental change

Can you explain why this is needed? In usecases I have seen, the entire IR typically transitions from signed to signless types but I have not seen the need for a mixed form, yet.

gpu.memset operations expects both arguments to have the same type:

%0 = arith.constant 0 : ui32
%1 = memef:alloca: memref<ui32>
gpu.memset %1, %0 : memref<ui32>, ui32

But there are no constant operations in "standard" dialects that can define unsigned constant, as a work around this memset can be defined with i32 types if we can cast the memref argument.

nicolasvasilache requested changes to this revision.Sep 19 2022, 4:14 AM

This seems very undesirable.

memref.reinterpret_cast could be a better place to have this type of behavior as you can also change the sizes, strides etc and would allow richer elemental type changes.

This revision now requires changes to proceed.Sep 19 2022, 4:14 AM

gpu.memset operations expects both arguments to have the same type:

%0 = arith.constant 0 : ui32
%1 = memef:alloca: memref<ui32>
gpu.memset %1, %0 : memref<ui32>, ui32

Would it also be possible to turn the target of the memset into a signless int? Is the fact that the memref is unsigned load bearing here or just an artifact?

I agree on cast being the wrong place, as it is concerned with shapes. I wonder why arith.bitcast rules out signed types. That seems the natural home for this, somehow.

ezhulenev abandoned this revision.Dec 14 2022, 1:27 PM