Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/lib/Analysis/VectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ bool llvm::isTriviallyScalarizable(Intrinsic::ID ID,
// https://github.com/llvm/llvm-project/issues/112408
switch (ID) {
case Intrinsic::frexp:
case Intrinsic::uadd_with_overflow:
return true;
}
return false;
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/Transforms/Scalarizer/sincos.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s

; Test to make sure that struct return intrinsics that are not `isTriviallyScalarizable` do not get scalarized.

define <4 x float> @test_(<4 x float> %Val) {
; CHECK-LABEL: define <4 x float> @test_(
; CHECK-SAME: <4 x float> [[VAL:%.*]]) {
; CHECK-NEXT: [[R:%.*]] = call { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float> [[VAL]])
; CHECK-NEXT: [[EL:%.*]] = extractvalue { <4 x float>, <4 x float> } [[R]], 0
; CHECK-NEXT: ret <4 x float> [[EL]]
;
%r = call { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float> %Val)
%el = extractvalue { <4 x float>, <4 x float> } %r, 0
ret <4 x float> %el
}

16 changes: 12 additions & 4 deletions llvm/test/Transforms/Scalarizer/uadd_overflow.ll
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt %s -passes='function(scalarizer)' -S | FileCheck %s

; Test to make sure that struct return intrinsics that are not `isTriviallyScalarizable` do not get scalarized.

define <3 x i32> @test_(<3 x i32> %a, <3 x i32> %b) {
; CHECK-LABEL: define <3 x i32> @test_(
; CHECK-SAME: <3 x i32> [[A:%.*]], <3 x i32> [[B:%.*]]) {
; CHECK-NEXT: [[R:%.*]] = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> [[B]], <3 x i32> [[B]])
; CHECK-NEXT: [[EL:%.*]] = extractvalue { <3 x i32>, <3 x i1> } [[R]], 0
; CHECK-NEXT: [[B_I0:%.*]] = extractelement <3 x i32> [[B]], i64 0
; CHECK-NEXT: [[R_I0:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[B_I0]], i32 [[B_I0]])
; CHECK-NEXT: [[B_I1:%.*]] = extractelement <3 x i32> [[B]], i64 1
; CHECK-NEXT: [[R_I1:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[B_I1]], i32 [[B_I1]])
; CHECK-NEXT: [[B_I2:%.*]] = extractelement <3 x i32> [[B]], i64 2
; CHECK-NEXT: [[R_I2:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[B_I2]], i32 [[B_I2]])
; CHECK-NEXT: [[EL_ELEM0:%.*]] = extractvalue { i32, i1 } [[R_I0]], 0
; CHECK-NEXT: [[EL_ELEM01:%.*]] = extractvalue { i32, i1 } [[R_I1]], 0
; CHECK-NEXT: [[EL_ELEM02:%.*]] = extractvalue { i32, i1 } [[R_I2]], 0
; CHECK-NEXT: [[EL_UPTO0:%.*]] = insertelement <3 x i32> poison, i32 [[EL_ELEM0]], i64 0
; CHECK-NEXT: [[EL_UPTO1:%.*]] = insertelement <3 x i32> [[EL_UPTO0]], i32 [[EL_ELEM01]], i64 1
; CHECK-NEXT: [[EL:%.*]] = insertelement <3 x i32> [[EL_UPTO1]], i32 [[EL_ELEM02]], i64 2
; CHECK-NEXT: ret <3 x i32> [[EL]]
;
%r = call { <3 x i32>, <3 x i1> } @llvm.uadd.with.overflow.v3i32(<3 x i32> %b, <3 x i32> %b)
Expand Down