[CodeGenPrepare] Move away sign extensions that get in the way of addressing

Press ? to show keyboard shortcuts.
Committed
qcolombetFeb 6 2014, 1:44 PM
Parents
rL200946: Use correct ld emulation for EABI hardware float triple on NetBSD.
Branches
Unknown
Tags
Unknown
Description

[CodeGenPrepare] Move away sign extensions that get in the way of addressing
mode.

Basically the idea is to transform code like this:
%idx = add nsw i32 %a, 1
%sextidx = sext i32 %idx to i64
%gep = gep i8* %myArray, i64 %sextidx
load i8* %gep

Into:
%sexta = sext i32 %a to i64
%idx = add nsw i64 %sexta, 1
%gep = gep i8* %myArray, i64 %idx
load i8* %gep

That way the computation can be folded into the addressing mode.

This transformation is done as part of the addressing mode matcher.
If the matching fails (not profitable, addressing mode not legal, etc.), the
matcher will revert the related promotions.

rdar://problem/15519855

rL200947

llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Loading...

llvm/trunk/test/CodeGen/X86/codegen-prepare-addrmode-sext.ll

Loading...

Add Comment