#1628 consequent if's with constant compile wrong

MSYS
open
gcc (462)
Bug
none
Unknown
False
2013-02-11
2012-03-02
No

I have found this situation then working with QEMU 0.15.1 project.

using mingw-get-inst-20111118

in process.c for target-arm

if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
/* PRIMASK */
if (insn & 2) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
/* FAULTMASK */
if (insn & 1) {
addr = tcg_const_i32(17);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);

if we just switch conditions order it will compile OK

if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
/* FAULTMASK */
if (insn & 1) {
addr = tcg_const_i32(17);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
/* PRIMASK */
if (insn & 2) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);

I have attached gdb disassembly in the attachment for both cases

Discussion

  • Earnie Boyd

    Earnie Boyd - 2012-03-02

    You need to also attach the small test case to build and give us the GCC parameters used to cause the effect.

     
  • Earnie Boyd

    Earnie Boyd - 2012-03-02
    • status: open --> pending
     
  • alex bondarenko

    alex bondarenko - 2012-03-02
    • status: pending --> open
     
  • alex bondarenko

    alex bondarenko - 2012-03-02
     
  • alex bondarenko

    alex bondarenko - 2012-03-02

    Submitted file bug.c

    compile with

    gcc.exe -O2 bug.c

     
  • Earnie Boyd

    Earnie Boyd - 2012-06-14
    • assigned_to: nobody --> cstrauss
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-11
    • milestone: --> MSYS
    • type: --> Bug
    • resolution: --> none
    • category: --> Unknown
    • patch_attached: --> False
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks