llvm.org GIT mirror
[SLP] limit vectorization of Constant subclasses (PR33958) This is a fix for: https://bugs.llvm.org/show_bug.cgi?id=33958 It seems universally true that we would not want to transform this kind of sequence on any target, but if that's not correct, then we could view this as a target-specific cost model problem. We could also white-list ConstantInt, ConstantFP, etc. rather than blacklist Global and ConstantExpr. Differential Revision: https://reviews.llvm.org/D67362 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371931 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel a month ago
2 changed file(s) with 14 addition(s) and 8 deletion(s).
 193 193 return true; 194 194 } 195 195 196 /// \returns True if all of the values in \p VL are constants.⏎ 196 /// \returns True if all of the values in \p VL are constants (but not⏎ 197 /// globals/constant expressions). 197 198 static bool allConstant(ArrayRef VL) { 199 // Constant expressions and globals can't be vectorized like normal integer/FP 200 // constants. 198 201 for (Value *i : VL) 199 if (!isa(i))⏎ 202 if (!isa(i) || isa(i) || isa(i))⏎ 200 203 return false; 201 204 return true; 202 205 }
 548 548 br i1 %cmp, label %for.body, label %for.cond.cleanup 549 549 } 550 550 551 ; Globals/constant expressions are not normal constants. 552 ; They should not be treated as the usual vectorization candidates. 553 551 554 @g1 = external global i32, align 4 552 555 @g2 = external global i32, align 4 553 556 554 557 define void @PR33958(i32** nocapture %p) { 555 558 ; CHECK-LABEL: @PR33958( 556 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32*, i32** [[P:%.*]], i64 1 557 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32** [[P]] to <2 x i32*>* 558 ; CHECK-NEXT: store <2 x i32*> , <2 x i32*>* [[TMP1]], align 8⏎ 559 ; CHECK-NEXT: store i32* @g1, i32** [[P:%.*]], align 8⏎ 560 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32*, i32** [[P]], i64 1 561 ; CHECK-NEXT: store i32* @g2, i32** [[ARRAYIDX1]], align 8 559 562 ; CHECK-NEXT: ret void 560 563 ; 561 564 store i32* @g1, i32** %p, align 8 566 569 567 570 define void @store_constant_expression(i64* %p) { 568 571 ; CHECK-LABEL: @store_constant_expression( 569 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i64, i64* [[P:%.*]], i64 1 570 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64* [[P]] to <2 x i64>* 571 ; CHECK-NEXT: store <2 x i64> , <2 x i64>* [[TMP1]], align 8⏎ 572 ; CHECK-NEXT: store i64 ptrtoint (i32* @g1 to i64), i64* [[P:%.*]], align 8⏎ 573 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 1 574 ; CHECK-NEXT: store i64 ptrtoint (i32* @g2 to i64), i64* [[ARRAYIDX1]], align 8 572 575 ; CHECK-NEXT: ret void 573 576 ; 574 577 store i64 ptrtoint (i32* @g1 to i64), i64* %p, align 8