<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64479>64479</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[bug][inline] compile with optimize option -O1 will get wrong result
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MLsheng
</td>
</tr>
</table>
<pre>
#### demo.c
```
#include "arm_neon.h"
#include <stdio.h>
__attribute__((noinline))
void test()
{
float32_t a1[] = {-0.0, -0.0, 0.0, 0.0};
float32_t b1[] = {0.0, 0.0, -0.0, -0.0};
float32x4_t a = vld1q_f32 (a1);
float32x4_t b = vld1q_f32 (b1);
float32x4_t c = vmaxnmq_f32 (a, b);
float32_t actual1[4];
vst1q_f32 (actual1, c);
for (int i = 0; i < 4; ++i)
printf("%f\n", actual1[i]);
}
int main ()
{
test();
return 0;
}
```
#### compile command
`clang demo.c -static -fno-caret-diagnostics -march=armv8-a -mfloat-abi=softfp -o demo`
#### right output
```
0.000000
0.000000
0.000000
0.000000
```
but with the optimize option -O1 -O2 -O3 etc. the output will be wrong:
```
-0.000000
-0.000000
0.000000
0.000000
```
I guess it's the noinline command `__attribute__((noinline))` not work:
add the compile option `-mllvm -opt-bisect-limit=56` the output is right, but with the option `-mllvm -opt-bisect-limit=57`,the output is wrong. my clang version: 15.0.4
#### opt pass
```
BISECT: running pass (1) Annotation2MetadataPass on [module]
BISECT: running pass (2) ForceFunctionAttrsPass on [module]
BISECT: running pass (3) InferFunctionAttrsPass on [module]
BISECT: running pass (4) LowerExpectIntrinsicPass on test
BISECT: running pass (5) SimplifyCFGPass on test
BISECT: running pass (6) SROAPass on test
BISECT: running pass (7) EarlyCSEPass on test
BISECT: running pass (8) LowerExpectIntrinsicPass on vmaxnmq_f32
BISECT: running pass (9) SimplifyCFGPass on vmaxnmq_f32
BISECT: running pass (10) SROAPass on vmaxnmq_f32
BISECT: running pass (11) EarlyCSEPass on vmaxnmq_f32
BISECT: running pass (12) LowerExpectIntrinsicPass on main
BISECT: running pass (13) SimplifyCFGPass on main
BISECT: running pass (14) SROAPass on main
BISECT: running pass (15) EarlyCSEPass on main
BISECT: running pass (16) OpenMPOptPass on [module]
BISECT: running pass (17) IPSCCPPass on [module]
BISECT: running pass (18) CalledValuePropagationPass on [module]
BISECT: running pass (19) GlobalOptPass on [module]
BISECT: running pass (20) PromotePass on test
BISECT: running pass (21) PromotePass on vmaxnmq_f32
BISECT: running pass (22) PromotePass on main
BISECT: running pass (23) DeadArgumentEliminationPass on [module]
BISECT: running pass (24) InstCombinePass on test
BISECT: running pass (25) SimplifyCFGPass on test
BISECT: running pass (26) InstCombinePass on vmaxnmq_f32
BISECT: running pass (27) SimplifyCFGPass on vmaxnmq_f32
BISECT: running pass (28) InstCombinePass on main
BISECT: running pass (29) SimplifyCFGPass on main
BISECT: running pass (30) InvalidateAnalysisPass<llvm::AAManager> on test
BISECT: running pass (31) InvalidateAnalysisPass<llvm::AAManager> on vmaxnmq_f32
BISECT: running pass (32) InvalidateAnalysisPass<llvm::AAManager> on main
BISECT: running pass (33) InlinerPass on (vmaxnmq_f32)
BISECT: running pass (34) InlinerPass on (vmaxnmq_f32)
BISECT: running pass (35) PostOrderFunctionAttrsPass on (vmaxnmq_f32)
BISECT: running pass (36) SROAPass on vmaxnmq_f32
BISECT: running pass (37) EarlyCSEPass on vmaxnmq_f32
BISECT: running pass (38) SimplifyCFGPass on vmaxnmq_f32
BISECT: running pass (39) InstCombinePass on vmaxnmq_f32
BISECT: running pass (40) LibCallsShrinkWrapPass on vmaxnmq_f32
BISECT: running pass (41) SimplifyCFGPass on vmaxnmq_f32
BISECT: running pass (42) ReassociatePass on vmaxnmq_f32
BISECT: running pass (43) LoopSimplifyPass on vmaxnmq_f32
BISECT: running pass (44) LCSSAPass on vmaxnmq_f32
BISECT: running pass (45) SimplifyCFGPass on vmaxnmq_f32
BISECT: running pass (46) InstCombinePass on vmaxnmq_f32
BISECT: running pass (47) LoopSimplifyPass on vmaxnmq_f32
BISECT: running pass (48) LCSSAPass on vmaxnmq_f32
BISECT: running pass (49) SROAPass on vmaxnmq_f32
BISECT: running pass (50) MemCpyOptPass on vmaxnmq_f32
BISECT: running pass (51) SCCPPass on vmaxnmq_f32
BISECT: running pass (52) BDCEPass on vmaxnmq_f32
BISECT: running pass (53) InstCombinePass on vmaxnmq_f32
BISECT: running pass (54) ADCEPass on vmaxnmq_f32
BISECT: running pass (55) SimplifyCFGPass on vmaxnmq_f32
BISECT: running pass (56) InstCombinePass on vmaxnmq_f32
BISECT: NOT running pass (57) InlinerPass on (test)
BISECT: NOT running pass (58) InlinerPass on (test)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysWF9v4roT_TTmxQpK7PyBBx4gwKrS9ke1Xf3uY-UkJviuY-faTru9n_7KDrS0hIWEItSY4nM8Mz4zHky0ZqWgdAaiBYiWI9KYnVSz--96R0U5ymTxOgMIv71hQSs5zoG_BP4cxP7-3X5EmImcNwWFACGiqidBpRjvAEKnE3CqTcHkeAfwav-t-_v0RIxRLGsMfXoCaALQREgmOBMUoKl9u2nPkhXQUG3clP0_QbJoBxBCuOWSGIyeDCRB6xwEeAlBsvD8sQ9QCg_Po0eyBLiTI_vE8RH6gfGI44Tpd2jtcSTPvAj-edpiBAGakMA60bG0A2SngOyPgLwFVOS3qN7XsBZmZ2DWrNw0hFs_QxB9jMOzNke27uehFOYnbFLZKUwYyJwNPsALN0xhaIcALQBaMICm8B1lX7ViwmzdbiKAoi2IUuGG6ZFhzBp2tKSNtRvYBSvCBDwrhyOtHBusqGmUcGZ-ojwV93sS5LKqGaf2WRFRvAFyTkQJ9zkCPW2IYTn0tkJ6OVHUeAUjpZDasFxD6FVE5TuAl0RVzxOPQK9yu-GRjAG81HJrtjWEnmwZu01RrNwZKBtTN6bTcH_su1ffT59ossbAF2Z20OwolLVhFfu3HUgBvU0AvQ2C3gZDavJxO8nZ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