llvm-project
36d19f50 - [MLIR][Mem2Reg] Ensure dominance of default value in regions (#193708)

Commit
8 days ago
[MLIR][Mem2Reg] Ensure dominance of default value in regions (#193708) When we promote an allocation, and a default value for a load from an uninitialized slot is required, this value used to get inserted in the same block as the allocation. However, in some cases, the default value needs to be available in the predecessor blocks so that they can pass it to the block of the allocation as an argument. For example, this is the case for loops containing an allocation where the promoted value will become and IV. Make sure the default value is always available to all blocks by creating it in the entry block of the region. For reference, this is what used to be the output for the test. Note the use of `%1`. ``` "func.func"() <{function_type = (f64) -> (), sym_name = "poison_insertion_point"}> ({ ^bb0(%arg0: f64): "cf.br"(%1)[^bb1] : (f64) -> () ^bb1(%0: f64): // 2 preds: ^bb0, ^bb2 %1 = "ub.poison"() <{value = #ub.poison}> : () -> f64 %2 = "test.get"() : () -> i1 "cf.cond_br"(%2)[^bb2, ^bb3] <{operandSegmentSizes = array<i32: 1, 0, 0>}> : (i1) -> () ^bb2: // pred: ^bb1 %3 = "test.get"() : () -> i1 %4 = "scf.if"(%3) ({ "scf.yield"(%arg0) : (f64) -> () }, { "scf.yield"(%0) : (f64) -> () }) : (i1) -> f64 "test.use"(%4) : (f64) -> () "cf.br"(%4)[^bb1] : (f64) -> () ^bb3: // pred: ^bb1 "func.return"() : () -> () }) : () -> () ```
Author
Parents
Loading