Page MenuHomePhabricator

[SDAG] Peek through bitcasts before commuting setcc operands

Authored by pengfei on Sep 22 2019, 6:38 PM.



This patch fix a bug result from D63958.

On X86 32 bit, BUILD_VECTOR <2 x i64> will be broke into a combine of BUILD_VECTOR <4 x i32> and bitcast. So we should peek through it, otherwise it may fall into dead loop in some cases. e.g.

1 define <2 x i64> @test(<2 x i64> %a) {
2   %1 = sub <2 x i64> zeroinitializer, %a
3   %2 = icmp eq <2 x i64> %a, zeroinitializer
4   %3 = select <2 x i1> %2, <2 x i64> %a, <2 x i64> %1
5   ret <2 x i64> %3
6 }

llc -mtriple=i686 -matttr=+avx512f -mattr=avx512vl t.ll

Event Timeline

pengfei created this revision.Sep 22 2019, 6:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2019, 6:38 PM

Please add a testcase

pengfei updated this revision to Diff 221245.Sep 22 2019, 7:08 PM

Add testcase. Thanks @xbolva00

I've removed the canonicalization in LowerIntVSETCC_AVX512 that was causing this in r372543. And I've moved it to X86ISelDAGToDAG in r372544. At the time LowerIntVSETCC_AVX512 we were using isel patterns for vptest and this was an attempt reduce the size of the table. We're now using custom isel in X86ISelDAGToDAG so the canonicalization is much cheaper to handle there.

pengfei abandoned this revision.Sep 23 2019, 6:06 AM

Craig had fixed this issue using a better solution. Abandoned.