[LLVMdev] IndVarSimplify too aggressive ?

Arnaud Allard de Grandmaison Arnaud.AllardDeGrandMaison at dibcom.com
Sun Mar 13 14:01:52 PDT 2011


Hi all,

The IndVarSimplify pass seems to be too aggressive when it enlarge the induction variable type ; this can pessimize the generated code when the new induction variable size is not natively supported by the target. This is probably not an issue for x86_64, which supports natively all types, but it is a real one for several embedded targets, with very few native types.

I attached a patch to address this issue; if TargetData is available, the patch attempts to keep the induction variable to a native type when going thru the induction variable users.

Also attached my test-case in C, as well as the resulting assembly output, with and without the patch applied, for arm and x86_32 targets. You will note the loop instructions count can be reduced by 30% in several cases.

The patch could probably be made smarter : I am welcoming all suggestions.

Best Regards,
--
Arnaud de Grandmaison
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IndVarSimplify-nativeType.patch
Type: application/octet-stream
Size: 2091 bytes
Desc: IndVarSimplify-nativeType.patch
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110313/71c8b9cc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-c
Size: 256 bytes
Desc: test.c
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110313/71c8b9cc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.s.patch.arm
Type: application/octet-stream
Size: 898 bytes
Desc: test.s.patch.arm
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110313/71c8b9cc/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.s.patch.x86_32
Type: application/octet-stream
Size: 2075 bytes
Desc: test.s.patch.x86_32
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110313/71c8b9cc/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.s.wo_patch.arm
Type: application/octet-stream
Size: 1102 bytes
Desc: test.s.wo_patch.arm
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110313/71c8b9cc/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.s.wo_patch.x86_32
Type: application/octet-stream
Size: 2304 bytes
Desc: test.s.wo_patch.x86_32
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110313/71c8b9cc/attachment-0004.obj>


More information about the llvm-dev mailing list