|
| 1 | +;=========================== begin_copyright_notice ============================ |
| 2 | +; |
| 3 | +; Copyright (C) 2025 Intel Corporation |
| 4 | +; |
| 5 | +; SPDX-License-Identifier: MIT |
| 6 | +; |
| 7 | +;============================ end_copyright_notice ============================= |
| 8 | + |
| 9 | +; RUN: igc_opt --opaque-pointers -igc-priv-mem-to-reg -S < %s 2>&1 | FileCheck %s |
| 10 | + |
| 11 | +; Verify that byte-wise (i8) GEPs with a non-constant index are NOT scalarized |
| 12 | +; by the legacy handleGEPInst path. The pass should skip transforming these to |
| 13 | +; avoid incorrect handling of inter-lane (unaligned) byte offsets. |
| 14 | +; The new algorithm (when enabled) can handle them, but is not used yet. |
| 15 | + |
| 16 | +; CHECK-LABEL: @test( |
| 17 | +; CHECK: for.body: |
| 18 | +; CHECK: %idx = phi i64 [ 0, %entry ], [ %idx.next, %for.body ] |
| 19 | +; CHECK: %src.gep = getelementptr i8, ptr {{%.*}}, i64 %idx |
| 20 | +; CHECK: %dst.gep = getelementptr i8, ptr {{%.*}}, i64 %idx |
| 21 | +; CHECK: load i8, ptr %src.gep |
| 22 | +; CHECK: store i8 |
| 23 | +; CHECK-NOT: insertelement |
| 24 | +; CHECK-NOT: extractelement |
| 25 | + |
| 26 | +define spir_kernel void @test() { |
| 27 | +entry: |
| 28 | + %src = alloca [64 x i32], align 4 |
| 29 | + %dst = alloca [64 x i32], align 4 |
| 30 | + br label %for.body |
| 31 | + |
| 32 | +for.body: ; preds = %entry, %for.body |
| 33 | + %idx = phi i64 [ 0, %entry ], [ %idx.next, %for.body ] |
| 34 | + %src.gep = getelementptr i8, ptr %src, i64 %idx |
| 35 | + %dst.gep = getelementptr i8, ptr %dst, i64 %idx |
| 36 | + %val = load i8, ptr %src.gep, align 1 |
| 37 | + store i8 %val, ptr %dst.gep, align 1 |
| 38 | + %idx.next = add nuw i64 %idx, 1 |
| 39 | + %exitcond = icmp eq i64 %idx.next, 256 ; 256 bytes = 64 * 4 |
| 40 | + br i1 %exitcond, label %exit, label %for.body |
| 41 | + |
| 42 | +exit: |
| 43 | + ret void |
| 44 | +} |
| 45 | + |
| 46 | +!igc.functions = !{!1} |
| 47 | +!1 = !{ptr @test, !2} |
| 48 | +!2 = !{!3} |
| 49 | +!3 = !{!"function_type", i32 0} |
0 commit comments