Skip to content

Commit 8cf0455

Browse files
committed
Use return type based CreateIntrinsic overload to fix crash with powi
Previously it was using the overloaded types constructor with a singleton arrayref: powi has multiple overloaded types
1 parent 3ab1864 commit 8cf0455

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
14531453
// intrinsic (shuf X, M), (shuf Y, M), ... --> shuf (intrinsic X, Y, ...), M
14541454
Instruction *FPI = isa<FPMathOperator>(II) ? II : nullptr;
14551455
Value *NewIntrinsic =
1456-
Builder.CreateIntrinsic(II->getIntrinsicID(), SrcTy, NewArgs, FPI);
1456+
Builder.CreateIntrinsic(SrcTy, II->getIntrinsicID(), NewArgs, FPI);
14571457
return new ShuffleVectorInst(NewIntrinsic, Mask);
14581458
}
14591459

llvm/test/Transforms/InstCombine/powi.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,30 @@ define double @powi_fmul_powi_x_overflow(double noundef %x) {
564564
%mul = fmul reassoc double %p1, %x
565565
ret double %mul
566566
}
567+
568+
define <3 x float> @powi_unary_shuffle_ops(<3 x float> %x, i32 %power) {
569+
; CHECK-LABEL: @powi_unary_shuffle_ops(
570+
; CHECK-NEXT: [[TMP1:%.*]] = call <3 x float> @llvm.powi.v3f32.i32(<3 x float> [[X:%.*]], i32 [[POWER:%.*]])
571+
; CHECK-NEXT: [[R:%.*]] = shufflevector <3 x float> [[TMP1]], <3 x float> poison, <3 x i32> <i32 1, i32 0, i32 2>
572+
; CHECK-NEXT: ret <3 x float> [[R]]
573+
;
574+
%sx = shufflevector <3 x float> %x, <3 x float> poison, <3 x i32> <i32 1, i32 0, i32 2>
575+
%r = call <3 x float> @llvm.powi(<3 x float> %sx, i32 %power)
576+
ret <3 x float> %r
577+
}
578+
579+
; Negative test - multiple uses
580+
581+
define <3 x float> @powi_unary_shuffle_ops_use(<3 x float> %x, i32 %power, ptr %p) {
582+
; CHECK-LABEL: @powi_unary_shuffle_ops_use(
583+
; CHECK-NEXT: [[SX:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> poison, <3 x i32> <i32 1, i32 0, i32 2>
584+
; CHECK-NEXT: store <3 x float> [[SX]], ptr [[P:%.*]], align 16
585+
; CHECK-NEXT: [[TMP1:%.*]] = call <3 x float> @llvm.powi.v3f32.i32(<3 x float> [[X]], i32 [[POWER:%.*]])
586+
; CHECK-NEXT: [[R:%.*]] = shufflevector <3 x float> [[TMP1]], <3 x float> poison, <3 x i32> <i32 1, i32 0, i32 2>
587+
; CHECK-NEXT: ret <3 x float> [[R]]
588+
;
589+
%sx = shufflevector <3 x float> %x, <3 x float> poison, <3 x i32> <i32 1, i32 0, i32 2>
590+
store <3 x float> %sx, ptr %p
591+
%r = call <3 x float> @llvm.powi(<3 x float> %sx, i32 %power)
592+
ret <3 x float> %r
593+
}

0 commit comments

Comments
 (0)