[PATCH] D63509: DAG: Use getStoreSize when expanding dynamic vector indexing
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 12:25:34 PDT 2019
arsenm created this revision.
arsenm added reviewers: efriedma, tlively, RKSimon.
Herald added subscribers: arphaman, aheejin, jgravelle-google, sbc100, wdng, dschuff.
I'm not sure why the FIXME was there, since the ABI size of the vector
shouldn't matter for the element offset.
Fixes bug 42304.
https://reviews.llvm.org/D63509
Files:
lib/CodeGen/SelectionDAG/TargetLowering.cpp
test/CodeGen/WebAssembly/bug42304.ll
Index: test/CodeGen/WebAssembly/bug42304.ll
===================================================================
--- /dev/null
+++ test/CodeGen/WebAssembly/bug42304.ll
@@ -0,0 +1,55 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=wasm32-unknown-unknown < %s | FileCheck %s
+
+define void @dynamic_vector_extract_nonpow2() {
+; CHECK-LABEL: dynamic_vector_extract_nonpow2:
+; CHECK: .functype dynamic_vector_extract_nonpow2 () -> ()
+; CHECK-NEXT: .local i32, i64
+; CHECK-NEXT: # %bb.0: # %bb
+; CHECK-NEXT: global.get __stack_pointer
+; CHECK-NEXT: i32.const 16
+; CHECK-NEXT: i32.sub
+; CHECK-NEXT: local.tee 0
+; CHECK-NEXT: i64.const 0
+; CHECK-NEXT: i64.store8 10
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i64.const 0
+; CHECK-NEXT: i64.store16 8
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i64.const 0
+; CHECK-NEXT: i64.store 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i32.load16_u 0
+; CHECK-NEXT: i32.const 1
+; CHECK-NEXT: i32.and
+; CHECK-NEXT: i32.const 6
+; CHECK-NEXT: i32.mul
+; CHECK-NEXT: i32.or
+; CHECK-NEXT: local.tee 0
+; CHECK-NEXT: i64.load32_u 0
+; CHECK-NEXT: local.tee 1
+; CHECK-NEXT: i64.store32 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: local.get 1
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: i32.const 4
+; CHECK-NEXT: i32.add
+; CHECK-NEXT: i64.load16_u 0
+; CHECK-NEXT: i64.const 32
+; CHECK-NEXT: i64.shl
+; CHECK-NEXT: i64.or
+; CHECK-NEXT: i64.const 4398046511103
+; CHECK-NEXT: i64.and
+; CHECK-NEXT: i64.const 32
+; CHECK-NEXT: i64.shr_u
+; CHECK-NEXT: i64.store16 0
+; CHECK-NEXT: # fallthrough-return-void
+; CHECK-NEXT: end_function
+bb:
+ %L = load i16, i16* undef
+ %E = extractelement <2 x i42> zeroinitializer, i16 %L
+ store i42 %E, i42* undef
+ ret void
+}
Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5570,9 +5570,7 @@
EVT EltVT = VecVT.getVectorElementType();
// Calculate the element offset and add it to the pointer.
- unsigned EltSize = EltVT.getSizeInBits() / 8; // FIXME: should be ABI size.
- assert(EltSize * 8 == EltVT.getSizeInBits() &&
- "Converting bits to bytes lost precision");
+ unsigned EltSize = EltVT.getStoreSize();
Index = clampDynamicVectorIndex(DAG, Index, VecVT, dl);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63509.205414.patch
Type: text/x-patch
Size: 2585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190618/2a380b49/attachment.bin>
More information about the llvm-commits
mailing list