PDL type and operands CSE behavior

Hi all,

I am experimenting a bit with PDL and I am surprised to see that the following:

module @patterns {
  pdl.pattern : benefit(1) {
    %0 = pdl.type
    %1 = pdl.type
    %2 = pdl.operand : %0
    %3 = pdl.operand : %1
    %4 = operation "foo"(%2, %3 : !pdl.value, !pdl.value)  -> (%1 : !pdl.type)
    pdl.rewrite %4 {
      pdl.erase %4
    }
  }
}

CSEs to:

module @patterns {
  pdl.pattern : benefit(1) {
    %0 = type
    %1 = operand : %0
    %2 = operation "foo"(%1, %1 : !pdl.value, !pdl.value)  -> (%0 : !pdl.type)
    rewrite %2 {
      erase %2
    }
  }
}

Is this expected and I should isolate my patterns better to never have CSE apply to them?

@River707

That is not expected, that is a bit off. I need to update the side effects of those operations to actually be accurate. Can you file a bug?

– River

https://github.com/llvm/llvm-project/issues/53863

Thanks!