Skip to content

Commit 2c367fb

Browse files
committed
[InstCombine] Precommit test exhibiting miscompile
InstCombine is determining incorrect byte offsets for GEPs into vectors of overaligned elements. Add a new testcase showing this behavior, serving as precommit for a fix.
1 parent 3e8b175 commit 2c367fb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

llvm/test/Transforms/InstCombine/getelementptr.ll

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

4-
target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64"
4+
target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64-f16:32"
55

66
%intstruct = type { i32 }
77
%pair = type { i32, i32 }
@@ -111,6 +111,20 @@ define void @test_evaluate_gep_as_ptrs_array(ptr addrspace(2) %B) {
111111
ret void
112112
}
113113

114+
define void @test_overaligned_vec(i8 %B) {
115+
; This should be turned into a constexpr instead of being an instruction
116+
; CHECK-LABEL: @test_overaligned_vec(
117+
; TODO: In this test case, half is overaligned to 32 bits.
118+
; Vectors are bit-packed and don't respect alignment.
119+
; Thus, the byte offset of the second half in <2 x half> is 2 bytes, not 4 bytes:
120+
; CHECK-NEXT: store i8 [[B:%.*]], ptr getelementptr inbounds ([10 x i8], ptr @Global, i64 0, i64 4), align 1
121+
; CHECK-NEXT: ret void
122+
;
123+
%A = getelementptr <2 x half>, ptr @Global, i64 0, i64 1
124+
store i8 %B, ptr %A
125+
ret void
126+
}
127+
114128
define ptr @test7(ptr %I, i64 %C, i64 %D) {
115129
; CHECK-LABEL: @test7(
116130
; CHECK-NEXT: [[A:%.*]] = getelementptr i32, ptr [[I:%.*]], i64 [[C:%.*]]

0 commit comments

Comments
 (0)