<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66039>66039</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
llvm-reduce should try to return intermediate values
</td>
</tr>
<tr>
<th>Labels</th>
<td>
enhancement,
new issue,
llvm-reduce
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
regehr
</td>
</tr>
</table>
<pre>
below is an example of a pattern I've seen happening a lot lately in the output of llvm-reduce, where the result of a miscompile gets stored to memory or used otherwise in some fashion, and the test case could be better reduced if we simply directly returned the incorrect value. in this case, the best value to return would be `%5`
the proposed reduction pass would cycle through SSA values in a function and then, one at a time, try to return each one (and then DCE the function, I guess)
I started work on this a couple times over the last few months but I'm just now facing up to the fact that I'm not going to have time in the foreseeable future, so putting this issue here in case someone has time to work on it
I'm not labeling this with "good first issue" since changing a function signature is more painful than I'd want to inflict on a first-timer
```llvm
; ModuleID = 'reduced.ll'
source_filename = "reduced.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @_Z8tf_2_foov(ptr %0, i64 %1) {
%3 = and i64 %1, -9223372036854775808
%4 = xor i64 %3, -9223372036854775808
%5 = sub nsw i64 %4, 1
%6 = trunc i64 %5 to i16
store i16 %6, ptr %0, align 2
ret void
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVc1yozoTfRp50-UUNObHCy8yyZeqLL7V7O4mJaABzQiJklomfvtbEibjzOpWuWQhzuk-LU5L0ns1GqKLKH-I8vUgA0_WXRyNNLlDa_vbpSVtV1AepAH6lPOiCewAEhbJTM7Au8D6SuCJDExyWcgoM4IEbRm0ZNI3UAZ4IrCBl8CRrfV1PjrqQ0cCX2CdyFGCOPJB85ZgVr6z86I0wUjswbN11ANbmGm27gbWQfDUg-WJ3Ko8xUTezgSD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