Open
Description
It appears LSR does not recognize that shift operations could be promoted to operate directly on 64-bit values instead of adding extra 32-bit truncation and sign-extension for ops on loop induction variables. E.g. direct 64-bit shifting compared to lea r9d, [8*rcx]
then movsxd r9, r9d
for i*8
and i<<3
respectively.
%35 = trunc nuw nsw i64 %indvars.iv to i32
%shl = shl i32 %35, 3
%idxprom = sext i32 %shl to i64
%arrayidx = getelementptr inbounds i32, ptr %src, i64 %idxprom
Godbolt test (timeout on Alive2).