[Bug target/96297] New: Redundant zero extension after inlining the function

bina2374 at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jul 23 09:03:41 GMT 2020


            Bug ID: 96297
           Summary: Redundant zero extension after inlining the function
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bina2374 at gmail dot com
                CC: kito at gcc dot gnu.org, wilson at gcc dot gnu.org
  Target Milestone: ---
            Target: riscv32-unknown-elf

Command line: bin/riscv64-unknown-elf-gcc -march=rv32imafc -mabi=ilp32f -O3
call_is_digit.c -S

 C Source
unsigned char is_digit(unsigned char c) {
  return ((c >= '0') & (c <= '9')) ? 1 : 0;

int call_is_digit(unsigned char c) {
  if (is_digit(c))
    return 0xa;
    return 0;

 GCC asm
        addi    a0,a0,-48
        sltiu   a0,a0,10

        addi    a0,a0,-48
        andi    a0,a0,0xff  # redundant zero extension
        li      a5,9
        bleu    a0,a5,.L5
        li      a0,0
        li      a0,10

The zero extension instruction in the function is_digit is eliminated in
combine pass, but it in the function call_is_digit can not be eliminated.

More information about the Gcc-bugs mailing list