tlopex opened a new pull request, #20058:
URL: https://github.com/apache/tvm/pull/20058

   This PR fixes invalid pointer arithmetic emitted by C-family codegen for 
vector-typed `tvm_access_ptr`.
   
   A vector access pointer is lowered to `address_of(BufferLoad(...))` with a 
`Ramp` index describing its lane indices. For example, `Ramp(4, 1, 2)` 
represents scalar elements `[4, 5]`, so its address should be the address of 
the first lane, `&A[4]`.
   
   LLVM codegen already extracts `Ramp::base` in this case. However, `CodeGenC` 
previously passed the complete ramp to pointer arithmetic, which could generate 
invalid CUDA code such as:
   
   ```cpp
   (float*)A + make_int2(4, 5)
   ```
   
   This PR makes `CodeGenC` use `Ramp::base` when generating the address of a 
vector `BufferLoad`. The normalized index is applied to both the direct 
pointer-offset path and the general `GetBufferRef` path.
   
   The existing scalar-buffer plus `Ramp` lowering is preserved. This avoids 
regressions for padded vector types such as `float32x3` and packed vector types 
such as `int4x4`, while making C-family codegen consistent with LLVM codegen.
   
   Regression tests cover:
   
   - `float32x2` C codegen.
   - Padded `float32x3` LLVM codegen.
   - Packed `int4x4` CUDA codegen.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to