[PATCH] D151141: [CodeGen] Fix crash in CodeGenPrepare::optimizeGatherScatterInst.
Joshua Cranmer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 22 14:13:17 PDT 2023
jcranmer-intel updated this revision to Diff 524487.
jcranmer-intel added a comment.
Move test again, add return.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151141/new/
https://reviews.llvm.org/D151141
Files:
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/test/Transforms/CodeGenPrepare/X86/masked-gather-struct-gep.ll
Index: llvm/test/Transforms/CodeGenPrepare/X86/masked-gather-struct-gep.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/CodeGenPrepare/X86/masked-gather-struct-gep.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt -S -codegenprepare < %s | FileCheck %s
+; REQUIRES: x86-registered-target
+target triple = "x86_64-pc-linux"
+
+%s = type <{ float, i32, i8, [3 x i8] }>
+
+declare <4 x float> @llvm.masked.gather.v4f32.v4p0(<4 x ptr>, i32 immarg, <4 x i1>, <4 x float>)
+
+define <4 x float> @foo(ptr %p) {
+; CHECK-LABEL: define <4 x float> @foo
+; CHECK-SAME: (ptr [[P:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast ptr [[P]] to ptr
+; CHECK-NEXT: [[TMP2:%.*]] = getelementptr float, ptr [[TMP1]], <4 x i32> zeroinitializer
+; CHECK-NEXT: [[GATHER:%.*]] = call <4 x float> @llvm.masked.gather.v4f32.v4p0(<4 x ptr> [[TMP2]], i32 0, <4 x i1> zeroinitializer, <4 x float> zeroinitializer)
+; CHECK-NEXT: ret <4 x float> [[GATHER]]
+;
+ %base.splatinsert = insertelement <4 x ptr> poison, ptr %p, i32 0
+ %base = shufflevector <4 x ptr> %base.splatinsert, <4 x ptr> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
+ %gep = getelementptr %s, <4 x ptr> %base, <4 x i64> zeroinitializer, <4 x i32> zeroinitializer
+ %gather = call <4 x float> @llvm.masked.gather.v4f32.v4p0(<4 x ptr> %gep, i32 0, <4 x i1> zeroinitializer, <4 x float> zeroinitializer)
+ ret <4 x float> %gather
+}
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5708,7 +5708,8 @@
// Create a scalar GEP if there are more than 2 operands.
if (Ops.size() != 2) {
// Replace the last index with 0.
- Ops[FinalIndex] = Constant::getNullValue(ScalarIndexTy);
+ Ops[FinalIndex] =
+ Constant::getNullValue(Ops[FinalIndex]->getType()->getScalarType());
Base = Builder.CreateGEP(SourceTy, Base, ArrayRef(Ops).drop_front());
SourceTy = GetElementPtrInst::getIndexedType(
SourceTy, ArrayRef(Ops).drop_front());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151141.524487.patch
Type: text/x-patch
Size: 2242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230522/f7413cf4/attachment.bin>
More information about the llvm-commits
mailing list