From f1999ebe15e292f87be24e4b0400d98fb9ca4d25 Mon Sep 17 00:00:00 2001 From: Pei Mu Date: Sun, 19 Mar 2023 16:56:03 +0000 Subject: [PATCH] skip matching the destination type of GEP when its operand is a aggregate type Addresses #647. --- ...753a104493ddf87c1e65fd165a3e3ed8ae721a.txt | 46 +++++++++++++++++++ ...newton-irPass-LLVMIR-shrinkTypeByRange.cpp | 14 +++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 analysis/statistics/4e753a104493ddf87c1e65fd165a3e3ed8ae721a.txt diff --git a/analysis/statistics/4e753a104493ddf87c1e65fd165a3e3ed8ae721a.txt b/analysis/statistics/4e753a104493ddf87c1e65fd165a3e3ed8ae721a.txt new file mode 100644 index 000000000..c0529ee8a --- /dev/null +++ b/analysis/statistics/4e753a104493ddf87c1e65fd165a3e3ed8ae721a.txt @@ -0,0 +1,46 @@ + +changeset: 1461:4e753a104493ddf87c1e65fd165a3e3ed8ae721a +char kNewtonVersion[] = "0.3-alpha-1461 (4e753a104493ddf87c1e65fd165a3e3ed8ae721a) (build 03-19-2023-16:52-pei@pei-G5-5500-Linux-5.19.0-35-generic-x86_64)"; +\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s +\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt + +Informational Report: +--------------------- +Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)... + + Kernel 0 is a valid kernel: + + 1 1 + -0.5 -0 + 1 0 + 0.5 0 + 0 -1 + -0 -1 + + + The ordering of parameters is: P1 P0 P3 P2 P4 P5 + + Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0) + + Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1) + + + Kernel 1 is a valid kernel: + + 1 0 + -0.5 1 + 1 -2 + 0.5 -1 + -0 -2 + 0 -2 + + + The ordering of parameters is: P1 P0 P3 P2 P4 P5 + + Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0) + + Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2) + + + + diff --git a/src/newton/newton-irPass-LLVMIR-shrinkTypeByRange.cpp b/src/newton/newton-irPass-LLVMIR-shrinkTypeByRange.cpp index 2b9f0ca41..528d10a33 100644 --- a/src/newton/newton-irPass-LLVMIR-shrinkTypeByRange.cpp +++ b/src/newton/newton-irPass-LLVMIR-shrinkTypeByRange.cpp @@ -294,7 +294,11 @@ getRawType(Type * inputType, std::vector indexValue = std::vectorgetContainedType(0); + if (0 != stType->getNumContainedTypes()) { + eleType = stType->getContainedType(0); + } else { + return stType; + } } else { @@ -916,6 +920,12 @@ matchDestType(State * N, Instruction * inInstruction, BasicBlock & llvmIrBasicBl { unsigned ptAddressSpace = srcType->getPointerAddressSpace(); srcType = srcType->getPointerElementType(); + if (srcType->isAggregateType()) { + /* + * we don't shrink the aggregate type + * */ + return; + } std::vector indexValue; for (size_t idx = 0; idx < inInstruction->getNumOperands() - 1; idx++) { @@ -1303,6 +1313,8 @@ bool matchCastType(State * N, Instruction * inInstruction, BasicBlock & llvmIrBa * %i = castInst type1 %op1 to type2 * store type %op1, type* %op2 * %.i = phi type [%op1, %bb1], [%op2, %bb2], ... + * + * todo: Either skip the aggregate type or analyze it. Mainly structure. * */ std::map shrinkInstType(State * N, BoundInfo * boundInfo, Function & llvmIrFunction)