diff --git a/.pick_status.json b/.pick_status.json index 8ec7f718adc..cba3b67e406 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2214,7 +2214,7 @@ "description": "elk/cmod: Don't propagate from CMP to ADD if there is a write between", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "020b0055e7a085a6a8c961ad12ce94e58606a1ae", "notes": null diff --git a/src/intel/compiler/elk/elk_fs_cmod_propagation.cpp b/src/intel/compiler/elk/elk_fs_cmod_propagation.cpp index dc5faa23960..7ae70a3a024 100644 --- a/src/intel/compiler/elk/elk_fs_cmod_propagation.cpp +++ b/src/intel/compiler/elk/elk_fs_cmod_propagation.cpp @@ -109,6 +109,17 @@ cmod_propagate_cmp_to_add(const intel_device_info *devinfo, elk_bblock_t *block, } foreach_inst_in_block_reverse_starting_from(elk_fs_inst, scan_inst, inst) { + /* If either of the sources of the CMP is modified, the optimization + * cannot occur. This is the case even if the instruction modifying the + * value is an ADD of the appropriate form. + */ + if (regions_overlap(scan_inst->dst, scan_inst->size_written, + inst->src[0], inst->size_read(0)) || + regions_overlap(scan_inst->dst, scan_inst->size_written, + inst->src[1], inst->size_read(1))) { + break; + } + if (scan_inst->opcode == ELK_OPCODE_ADD && !scan_inst->is_partial_write() && scan_inst->exec_size == inst->exec_size) {