[llvm] [CGP] Reassociate GEPs to separate scalar and vector indexing (PR #146379)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 09:02:00 PDT 2025


================
@@ -112,7 +112,9 @@ define void @splat_ptr_scatter(ptr %ptr, <4 x i1> %mask, <4 x i32> %val) {
 
 define <4 x i32> @scalar_prefix(ptr %base, i64 %index, <4 x i64> %vecidx) {
 ; CHECK-LABEL: @scalar_prefix(
-; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], i64 [[INDEX:%.*]], <4 x i64> [[VECIDX:%.*]]
+; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr [256 x i32], ptr [[BASE:%.*]], i64 [[INDEX:%.*]], i64 0
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast ptr [[TMP1]] to ptr
----------------
preames wrote:

This bitcast comes from the fact we run both the new and old transformation (i.e. CGP iterates once).  We've got a minor missed optimization where this bitcast could be entirely pruned.  

https://github.com/llvm/llvm-project/pull/146379


More information about the llvm-commits mailing list