https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124022
Bug ID: 124022
Summary: Eliminate extensions made unnecessary to due ABI
mandates
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: law at gcc dot gnu.org
Target Milestone: ---
Consider this (523.xalan) for rv64gcbv_zicond:
void normalizeAttValue(unsigned short nextCh, int* res) {
if ( (nextCh <= 13) &&
(nextCh == 9 || nextCh == 10 || nextCh == 13)) {
*res +=5;
}
}
We get code like this:
normalizeAttValue:
li a4,13 # 8 [c=4 l=4] *movdi_64bit/1
sext.w a5,a0 # 7 [c=4 l=4] *extendsidi2_internal/0
bgtu a0,a4,.L2 # 9 [c=16 l=4] *branchdi
addiw a0,a0,-9 # 11 [c=8 l=4] addsi3_extended/1
zext.h a0,a0 # 14 [c=4 l=4] *zero_extendhidi2_bitmanip/0
addi a5,a5,-13 # 22 [c=4 l=4] *adddi3/1
sltiu a0,a0,2 # 17 [c=4 l=4] *sleu_didi
seqz a5,a5 # 23 [c=4 l=4] *seq_zero_didi
or a0,a0,a5 # 28 [c=4 l=4] *iordi3/0
beq a0,zero,.L2 # 29 [c=16 l=4] *branchdi
lw a5,0(a1) # 31 [c=28 l=4]
*extendsidi2_internal/1
addiw a5,a5,5 # 33 [c=8 l=4] addsi3_extended/1
sw a5,0(a1) # 35 [c=4 l=4] *movsi_internal/3
That first sext.w looks redundant. The ABI mandates that subword objects are
extended to 32 bits according to their type, then *sign* extended from 32 to 64
bits. Thus we already know the value in a0 was sign extended from SI to DI.
Combine has some code to track this as does ree.