llvm.org GIT mirror llvm / 71f28d6
[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). Raw diff Collapse all Expand all
193193 return true;
194194 }
195195
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).
197198 static bool allConstant(ArrayRef VL) {
199 // Constant expressions and globals can't be vectorized like normal integer/FP
200 // constants.
198201 for (Value *i : VL)
199 if (!isa(i))
202 if (!isa(i) || isa(i) || isa(i))
200203 return false;
201204 return true;
202205 }
548548 br i1 %cmp, label %for.body, label %for.cond.cleanup
549549 }
550550
551 ; Globals/constant expressions are not normal constants.
552 ; They should not be treated as the usual vectorization candidates.
553
551554 @g1 = external global i32, align 4
552555 @g2 = external global i32, align 4
553556
554557 define void @PR33958(i32** nocapture %p) {
555558 ; 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
559562 ; CHECK-NEXT: ret void
560563 ;
561564 store i32* @g1, i32** %p, align 8
566569
567570 define void @store_constant_expression(i64* %p) {
568571 ; 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
572575 ; CHECK-NEXT: ret void
573576 ;
574577 store i64 ptrtoint (i32* @g1 to i64), i64* %p, align 8