Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/InstructionSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6474,6 +6474,10 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
const CallBase *Call) {
unsigned BitWidth = ReturnType->getScalarSizeInBits();
switch (IID) {
case Intrinsic::get_active_lane_mask:
if (match(Op1, m_Zero()))
return ConstantInt::getFalse(ReturnType);
break;
case Intrinsic::abs:
// abs(abs(x)) -> abs(x). We don't need to worry about the nsw arg here.
// It is always ok to pick the earlier abs. We'll just lose nsw if its only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ entry:
define <vscale x 16 x i1> @nxv16i1_constexpr_0() {
; CHECK-LABEL: @nxv16i1_constexpr_0(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[MASK:%.*]] = call <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i64(i64 ptrtoint (ptr @glob to i64), i64 0)
; CHECK-NEXT: ret <vscale x 16 x i1> [[MASK]]
; CHECK-NEXT: ret <vscale x 16 x i1> zeroinitializer
;
entry:
%mask = call <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i64(i64 ptrtoint (ptr @glob to i64), i64 0)
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/Transforms/InstSimplify/get_active_lane_mask.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instsimplify,verify -S | FileCheck %s

define <4 x i1> @foo_v4i1(i32 %a) {
; CHECK-LABEL: define <4 x i1> @foo_v4i1(
; CHECK-SAME: i32 [[A:%.*]]) {
; CHECK-NEXT: ret <4 x i1> zeroinitializer
;
%mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1(i32 %a, i32 0)
ret <4 x i1> %mask
}

define <vscale x 8 x i1> @foo_nxv8i1(i32 %a) {
; CHECK-LABEL: define <vscale x 8 x i1> @foo_nxv8i1(
; CHECK-SAME: i32 [[A:%.*]]) {
; CHECK-NEXT: ret <vscale x 8 x i1> zeroinitializer
;
%mask = call <vscale x 8 x i1> @llvm.get.active.lane.mask.nxv8i1(i32 %a, i32 0)
ret <vscale x 8 x i1> %mask
}