https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96297
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; else return 0; } ========= GCC asm ========= is_digit: addi a0,a0,-48 sltiu a0,a0,10 ret call_is_digit: addi a0,a0,-48 andi a0,a0,0xff # redundant zero extension li a5,9 bleu a0,a5,.L5 li a0,0 ret .L5: li a0,10 ret 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.