|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt -consthoist -consthoist-gep -S -o - %s | FileCheck %s |
| 3 | + |
| 4 | +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 5 | +target triple = "thumbv6m-none--musleabi" |
| 6 | + |
| 7 | +%0 = type { [10 x i32], [10 x i16] } |
| 8 | + |
| 9 | +@global = external local_unnamed_addr global %0, align 4 |
| 10 | + |
| 11 | +define void @test_inbounds() { |
| 12 | +; CHECK-LABEL: @test_inbounds( |
| 13 | +; CHECK-NEXT: bb: |
| 14 | +; CHECK-NEXT: [[CONST:%.*]] = bitcast i16* getelementptr inbounds ([[TMP0:%.*]], %0* @global, i32 0, i32 1, i32 0) to i16* |
| 15 | +; CHECK-NEXT: store i16 undef, i16* [[CONST]], align 2 |
| 16 | +; CHECK-NEXT: [[BASE_BITCAST:%.*]] = bitcast i16* [[CONST]] to i8* |
| 17 | +; CHECK-NEXT: [[MAT_GEP:%.*]] = getelementptr i8, i8* [[BASE_BITCAST]], i32 2 |
| 18 | +; CHECK-NEXT: [[MAT_BITCAST:%.*]] = bitcast i8* [[MAT_GEP]] to i16* |
| 19 | +; CHECK-NEXT: store i16 undef, i16* [[MAT_BITCAST]], align 2 |
| 20 | +; CHECK-NEXT: [[BASE_BITCAST1:%.*]] = bitcast i16* [[CONST]] to i8* |
| 21 | +; CHECK-NEXT: [[MAT_GEP2:%.*]] = getelementptr i8, i8* [[BASE_BITCAST1]], i32 20 |
| 22 | +; CHECK-NEXT: [[MAT_BITCAST3:%.*]] = bitcast i8* [[MAT_GEP2]] to i16* |
| 23 | +; CHECK-NEXT: store i16 undef, i16* [[MAT_BITCAST3]], align 2 |
| 24 | +; CHECK-NEXT: ret void |
| 25 | +; |
| 26 | +bb: |
| 27 | + store i16 undef, i16* getelementptr inbounds (%0, %0* @global, i32 0, i32 1, i32 0) |
| 28 | + store i16 undef, i16* getelementptr inbounds (%0, %0* @global, i32 0, i32 1, i32 1) |
| 29 | + store i16 undef, i16* getelementptr inbounds (%0, %0* @global, i32 0, i32 1, i32 10) |
| 30 | + ret void |
| 31 | +} |
| 32 | + |
| 33 | +define dso_local void @test_non_inbounds() { |
| 34 | +; CHECK-LABEL: @test_non_inbounds( |
| 35 | +; CHECK-NEXT: bb: |
| 36 | +; CHECK-NEXT: store i16 undef, i16* getelementptr inbounds ([[TMP0:%.*]], %0* @global, i32 0, i32 1, i32 11), align 2 |
| 37 | +; CHECK-NEXT: store i16 undef, i16* getelementptr ([[TMP0]], %0* @global, i32 0, i32 1, i32 12), align 2 |
| 38 | +; CHECK-NEXT: ret void |
| 39 | +; |
| 40 | +bb: |
| 41 | + store i16 undef, i16* getelementptr inbounds (%0, %0* @global, i32 0, i32 1, i32 11) |
| 42 | + store i16 undef, i16* getelementptr (%0, %0* @global, i32 0, i32 1, i32 12) |
| 43 | + ret void |
| 44 | +} |
| 45 | + |
0 commit comments