llvm.org GIT mirror llvm / 9f2b406
Merging r355116 and r355117: ------------------------------------------------------------------------ r355116 | ctopper | 2019-02-28 19:49:29 +0100 (Thu, 28 Feb 2019) | 7 lines [X86] Don't peek through bitcasts before checking ISD::isBuildVectorOfConstantSDNodes in combineTruncatedArithmetic We don't have any combines that can look through a bitcast to truncate a build vector of constants. So the truncate will stick around and give us something like this pattern (binop (trunc X), (trunc (bitcast (build_vector)))) which has two truncates in it. Which will be reversed by hoistLogicOpWithSameOpcodeHands in the generic DAG combiner. Thus causing an infinite loop. Even if we had a combine for (truncate (bitcast (build_vector))), I think it would need to be implemented in getNode otherwise DAG combiner visit ordering would probably still visit the binop first and reverse it. Or combineTruncatedArithmetic would need to do its own constant folding. Differential Revision: https://reviews.llvm.org/D58705 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r355117 | ctopper | 2019-02-28 19:50:16 +0100 (Thu, 28 Feb 2019) | 1 line [X86] Add test case that was supposed to go with r355116. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@355310 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 months ago
2 changed file(s) with 27 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3813338133 return true;
3813438134
3813538135 // See if this is a single use constant which can be constant folded.
38136 SDValue BC = peekThroughOneUseBitcasts(Op);
38137 return ISD::isBuildVectorOfConstantSDNodes(BC.getNode());
38136 // NOTE: We don't peek throught bitcasts here because there is currently
38137 // no support for constant folding truncate+bitcast+vector_of_constants. So
38138 // we'll just send up with a truncate on both operands which will
38139 // get turned back into (truncate (binop)) causing an infinite loop.
38140 return ISD::isBuildVectorOfConstantSDNodes(Op.getNode());
3813838141 };
3813938142
3814038143 auto TruncateArithmetic = [&](SDValue N0, SDValue N1) {
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=avx2 | FileCheck %s
2
3 ; Make sure this sequence doesn't hang in DAG combine.
4
5 define <8 x i32> @foo(<8 x i64> %x, <4 x i64> %y) {
6 ; CHECK-LABEL: foo:
7 ; CHECK: # %bb.0:
8 ; CHECK-NEXT: vandps %ymm2, %ymm0, %ymm0
9 ; CHECK-NEXT: vandps {{\.LCPI.*}}, %ymm1, %ymm1
10 ; CHECK-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[0,2,2,3,4,6,6,7]
11 ; CHECK-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[0,2,2,3]
12 ; CHECK-NEXT: vpermilps {{.*#+}} ymm1 = ymm1[0,2,2,3,4,6,6,7]
13 ; CHECK-NEXT: vpermpd {{.*#+}} ymm1 = ymm1[0,2,2,3]
14 ; CHECK-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
15 ; CHECK-NEXT: retl
16 %a = shufflevector <4 x i64> %y, <4 x i64> , <8 x i32>
17 %b = and <8 x i64> %x, %a
18 %c = trunc <8 x i64> %b to <8 x i32>
19 ret <8 x i32> %c
20 }
21