[Bug target/71519] New: "Out of range operand" bteqz inst generated by "casesi_internal_mips16_<mode>"

yszhou4tech at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 13 10:00:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71519

            Bug ID: 71519
           Summary: "Out of range operand" bteqz inst generated by
                    "casesi_internal_mips16_<mode>"
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yszhou4tech at gmail dot com
  Target Milestone: ---

There is a big switch statement in pcre_exec.c bundled with erlang 17.5.  When
cross compiling it with GCC 5.3.0 with MIPS16 enabled, the generated assembly
code contains a bteqz instruction with out of range target label

```
mips-openwrt-linux-musl-gcc -c -Werror=return-type -Os -pipe -mno-branch-likely
-mips32r2 -mtune=24kc -g3 -fno-caller-saves -fno-plt -fhonour-copts
-Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float
-mips16 -minterlink-mips16 -iremap
/home/yousong/git-repo/lede/build_dir/target-mips_24kc_musl-1.1.14/otp_src_17.5:otp_src_17.5
-Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1
-Wl,-z,now -Wl,-z,relro -D_GNU_SOURCE
-I/home/yousong/git-repo/lede/build_dir/target-mips_24kc_musl-1.1.14/otp_src_17.5/erts/mips-openwrt-linux-gnu
-fno-tree-copyrename
-I/home/yousong/git-repo/lede/staging_dir/target-mips_24kc_musl-1.1.14/usr/include
-I/home/yousong/git-repo/lede/staging_dir/target-mips_24kc_musl-1.1.14/include
-I/home/yousong/git-repo/lede/staging_dir/toolchain-mips_24kc_gcc-5.3.0_musl-1.1.14/usr/include
-I/home/yousong/git-repo/lede/staging_dir/toolchain-mips_24kc_gcc-5.3.0_musl-1.1.14/include/fortify
-I/home/yousong/git-repo/lede/staging_dir/toolchain-mips_24kc_gcc-5.3.0_musl-1.1.14/include
-D_GNU_SOURCE -DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wmissing-prototypes
-Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT
-DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -DERLANG_INTEGRATION -o
/home/yousong/git-repo/lede/build_dir/target-mips_24kc_musl-1.1.14/otp_src_17.5/erts/emulator/pcre/obj/mips-openwrt-linux-gnu/opt/pcre_exec.o
/home/yousong/git-repo/lede/build_dir/target-mips_24kc_musl-1.1.14/otp_src_17.5/erts/emulator/pcre/pcre_exec.c
{standard input}: Assembler messages:
{standard input}:1946: Error: operand value out of range for instruction
```

The generated code are like the following

```
1944     .loc 1 848 0
1945     sltu    $2, 156
1946     bteqz   $L125
1947     sll $3, $2, 2
1948     la  $2, $L127
1949     addu    $3, $2, $3
1950     lw  $3, 0($3)
1951     addu    $2, $2, $3
1952     j   $2
1953     .align  2
1954     .align  2
1955 $L127:
1956     .word   $L126-$L127
1957     .word   $L128-$L127
1958     .word   $L129-$L127
1959     .word   $L130-$L127
1960     .word   $L131-$L127
...
49207 $L125:
49208 $LBE2372 = .
49209 $LBB2374 = .
49210     .loc 1 6452 0
49211     lw  $16,0($16)
49212 $LVL4091 = .
```


More information about the Gcc-bugs mailing list