This is an archive of the discontinued LLVM Phabricator instance.

An infinite loop bug in DAG Combine about keeping transfering between any_extend and sign_extend
Needs ReviewPublic

Authored by HaoLiu on Apr 16 2014, 2:25 AM.

Details

Reviewers
t.p.northover
Summary

Hi Tim and other reviewers,

A simple test case can cause the DAG combiner keeps runing endlessly. To reproduce by using the test case in the patch:

$llc -march=arm64 -debug-only=dagcombine < test.ll
...
Replacing.2 0x3d08ad8: v4i32 = sign_extend 0x3d089d0 [ORD=3] [ID=-3]
With: 0x3d08190: v4i32 = any_extend 0x3d089d0 [ORD=3]

Replacing.3 0x3d08190: v4i32 = any_extend 0x3d089d0 [ORD=3]
With: 0x3d08ad8: v4i32 = sign_extend 0x3d089d0 [ORD=3]

Replacing.2 0x3d08ad8: v4i32 = sign_extend 0x3d089d0 [ORD=3]
With: 0x3d08190: v4i32 = any_extend 0x3d089d0 [ORD=3]
...

It tries to transfer sign_extend to any_extend, after that it will transfer back from any_extend to sign_extend ...

To fix this, one side of transformation should be stopped. As I think it makes no sense to transfer from any_extend to sign_extend ( it replace undefined bits with signed bits), this patch will stop transfering any_extend to sign_extend.

A regression test vselect.ll in ARM64 backend will fail. With this patch, it will generate 3 shift instructions other than 1 SSHLL instruction. To let it pass, I remove a CHECK conditon in vselect.ll. This can be improved in ARM64 backend in the future, so I also add a FIXME in vselect.ll.

Review please.

Thanks,
-Hao

Diff Detail

Event Timeline

Hi Hao,

I think this change looks reasonable. I like the tidy-up.

Tim.