The variable Res is updated, however, the debug location is dropped, According to the LLVM debug location update guideline (https://llvm.org/docs/HowToUpdateDebugInfo.html), it seems that the debug location should be kept.
Here is the optimization result for the test case.
Before:
call void @llvm.assume(i1 %c1), !dbg !16 %rem = srem i8 %x, %y, !dbg !17 call void @llvm.dbg.value(metadata i8 %rem, metadata !12, metadata !DIExpression()), !dbg !17
After
call void @llvm.assume(i1 %c1), !dbg !16 %x.nonneg = sub i8 0, %x, !dbg !17 %y.nonneg = sub i8 0, %y, !dbg !17 %rem1 = urem i8 %x.nonneg, %y.nonneg, !dbg !17 %rem1.neg = sub i8 0, %rem1 call void @llvm.dbg.value(metadata i8 %rem1.neg, metadata !12, metadata !DIExpression()), !dbg !17
It seems that there is no reason to drop the debug location for %rem1.neg
There's nothing incorrect with the COM directive here, but it's generally only needed if the commented line actually contains a directive.