[llvm] r356094 - Verifier: Make sure masked load/store alignment is a power of 2
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 12:46:35 PDT 2019
Author: arsenm
Date: Wed Mar 13 12:46:34 2019
New Revision: 356094
URL: http://llvm.org/viewvc/llvm-project?rev=356094&view=rev
Log:
Verifier: Make sure masked load/store alignment is a power of 2
The same should also be done for scatter/gather, but the verifier
doesn't check those at all now.
Added:
llvm/trunk/test/Verifier/masked-load.ll
llvm/trunk/test/Verifier/masked-store.ll
Modified:
llvm/trunk/lib/IR/Verifier.cpp
llvm/trunk/test/Assembler/auto_upgrade_intrinsics.ll
llvm/trunk/test/Transforms/InstCombine/masked_intrinsics.ll
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=356094&r1=356093&r2=356094&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Wed Mar 13 12:46:34 2019
@@ -4500,11 +4500,13 @@ void Verifier::visitIntrinsicCall(Intrin
Call);
Value *Ptr = Call.getArgOperand(0);
- // Value *Alignment = Call.getArgOperand(1);
+ ConstantInt *Alignment = cast<ConstantInt>(Call.getArgOperand(1));
Value *Mask = Call.getArgOperand(2);
Value *PassThru = Call.getArgOperand(3);
Assert(Mask->getType()->isVectorTy(), "masked_load: mask must be vector",
Call);
+ Assert(Alignment->getValue().isPowerOf2(),
+ "masked_load: alignment must be a power of 2", Call);
// DataTy is the overloaded type
Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType();
@@ -4520,10 +4522,12 @@ void Verifier::visitIntrinsicCall(Intrin
case Intrinsic::masked_store: {
Value *Val = Call.getArgOperand(0);
Value *Ptr = Call.getArgOperand(1);
- // Value *Alignment = Call.getArgOperand(2);
+ ConstantInt *Alignment = cast<ConstantInt>(Call.getArgOperand(2));
Value *Mask = Call.getArgOperand(3);
Assert(Mask->getType()->isVectorTy(), "masked_store: mask must be vector",
Call);
+ Assert(Alignment->getValue().isPowerOf2(),
+ "masked_store: alignment must be a power of 2", Call);
// DataTy is the overloaded type
Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType();
Modified: llvm/trunk/test/Assembler/auto_upgrade_intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/auto_upgrade_intrinsics.ll?rev=356094&r1=356093&r2=356094&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/auto_upgrade_intrinsics.ll (original)
+++ llvm/trunk/test/Assembler/auto_upgrade_intrinsics.ll Wed Mar 13 12:46:34 2019
@@ -80,7 +80,7 @@ declare void @llvm.masked.store.v2f64(<2
define void @tests.masked.store(<2 x double>* %ptr, <2 x i1> %mask, <2 x double> %val) {
; CHECK-LABEL: @tests.masked.store(
; CHECK: @llvm.masked.store.v2f64.p0v2f64
- call void @llvm.masked.store.v2f64(<2 x double> %val, <2 x double>* %ptr, i32 3, <2 x i1> %mask)
+ call void @llvm.masked.store.v2f64(<2 x double> %val, <2 x double>* %ptr, i32 4, <2 x i1> %mask)
ret void
}
Modified: llvm/trunk/test/Transforms/InstCombine/masked_intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/masked_intrinsics.ll?rev=356094&r1=356093&r2=356094&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/masked_intrinsics.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/masked_intrinsics.ll Wed Mar 13 12:46:34 2019
@@ -54,7 +54,7 @@ define void @store_zeromask(<2 x double>
; CHECK-LABEL: @store_zeromask(
; CHECK-NEXT: ret void
;
- call void @llvm.masked.store.v2f64.p0v2f64(<2 x double> %val, <2 x double>* %ptr, i32 3, <2 x i1> zeroinitializer)
+ call void @llvm.masked.store.v2f64.p0v2f64(<2 x double> %val, <2 x double>* %ptr, i32 4, <2 x i1> zeroinitializer)
ret void
}
Added: llvm/trunk/test/Verifier/masked-load.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/masked-load.ll?rev=356094&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/masked-load.ll (added)
+++ llvm/trunk/test/Verifier/masked-load.ll Wed Mar 13 12:46:34 2019
@@ -0,0 +1,10 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+declare <2 x double> @llvm.masked.load.v2f64.p0v2f64(<2 x double>*, i32, <2 x i1>, <2 x double>)
+
+define <2 x double> @masked_load(<2 x i1> %mask, <2 x double>* %addr, <2 x double> %dst) {
+ ; CHECK: masked_load: alignment must be a power of 2
+ ; CHECK-NEXT: %res = call <2 x double> @llvm.masked.load.v2f64.p0v2f64(<2 x double>* %addr, i32 3, <2 x i1> %mask, <2 x double> %dst)
+ %res = call <2 x double> @llvm.masked.load.v2f64.p0v2f64(<2 x double>* %addr, i32 3, <2 x i1>%mask, <2 x double> %dst)
+ ret <2 x double> %res
+}
Added: llvm/trunk/test/Verifier/masked-store.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/masked-store.ll?rev=356094&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/masked-store.ll (added)
+++ llvm/trunk/test/Verifier/masked-store.ll Wed Mar 13 12:46:34 2019
@@ -0,0 +1,10 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+declare void @llvm.masked.store.v4i32.p0v4i32(<4 x i32>, <4 x i32>*, i32, <4 x i1>)
+
+define void @masked_store(<4 x i1> %mask, <4 x i32>* %addr, <4 x i32> %val) {
+ ; CHECK: masked_store: alignment must be a power of 2
+ ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0v4i32(<4 x i32> %val, <4 x i32>* %addr, i32 3, <4 x i1> %mask)
+ call void @llvm.masked.store.v4i32.p0v4i32(<4 x i32> %val, <4 x i32>* %addr, i32 3, <4 x i1> %mask)
+ ret void
+}
More information about the llvm-commits
mailing list