forked from OSchip/llvm-project
[mlir] Fix bug in block merging when the types of the operands differ
The merging algorithm was previously not checking for type equivalence. Fixes PR47314 Differential Revision: https://reviews.llvm.org/D86594
This commit is contained in:
parent
3050713798
commit
474f7639e3
|
@ -497,6 +497,9 @@ LogicalResult BlockMergeCluster::addToCluster(BlockEquivalenceData &blockData) {
|
||||||
Value rhsOperand = rhsOperands[operand];
|
Value rhsOperand = rhsOperands[operand];
|
||||||
if (lhsOperand == rhsOperand)
|
if (lhsOperand == rhsOperand)
|
||||||
continue;
|
continue;
|
||||||
|
// Check that the types of the operands match.
|
||||||
|
if (lhsOperand.getType() != rhsOperand.getType())
|
||||||
|
return failure();
|
||||||
|
|
||||||
// Check that these uses are both external, or both internal.
|
// Check that these uses are both external, or both internal.
|
||||||
bool lhsIsInBlock = lhsOperand.getParentBlock() == leaderBlock;
|
bool lhsIsInBlock = lhsOperand.getParentBlock() == leaderBlock;
|
||||||
|
|
|
@ -202,3 +202,25 @@ func @mismatch_loop(%cond : i1) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that blocks are not merged if the types of the operands differ.
|
||||||
|
|
||||||
|
// CHECK-LABEL: func @mismatch_operand_types(
|
||||||
|
func @mismatch_operand_types(%arg0 : i1, %arg1 : memref<i32>, %arg2 : memref<i1>) {
|
||||||
|
%c0_i32 = constant 0 : i32
|
||||||
|
%true = constant true
|
||||||
|
br ^bb1
|
||||||
|
|
||||||
|
^bb1:
|
||||||
|
cond_br %arg0, ^bb2, ^bb3
|
||||||
|
|
||||||
|
^bb2:
|
||||||
|
// CHECK: store %{{.*}}, %{{.*}} : memref<i32>
|
||||||
|
store %c0_i32, %arg1[] : memref<i32>
|
||||||
|
br ^bb1
|
||||||
|
|
||||||
|
^bb3:
|
||||||
|
// CHECK: store %{{.*}}, %{{.*}} : memref<i1>
|
||||||
|
store %true, %arg2[] : memref<i1>
|
||||||
|
br ^bb1
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue