[NFC][Codegen] Add miscompile test for constant store merging from PR43446
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 25 Feb 2020 17:07:15 +0000 (20:07 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 25 Feb 2020 17:30:12 +0000 (20:30 +0300)
This miscompile was introduced by rL354676 / https://reviews.llvm.org/D58468

https://bugs.llvm.org/show_bug.cgi?id=43446

llvm/test/CodeGen/X86/stores-merging.ll

index 25c93c3..5ef1d9f 100644 (file)
@@ -219,3 +219,26 @@ define void @extract_vector_store_32_consecutive_bytes(<4 x i64> %v, i8* %ptr) #
   ret void
 }
 
+; These are miscompiles - we should store '1', not '-1'.
+; https://bugs.llvm.org/show_bug.cgi?id=43446
+define void @pr43446_0(i64 %x) {
+; CHECK-LABEL: pr43446_0:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movb $-1, (%rdi)
+; CHECK-NEXT:    retq
+  %a = inttoptr i64 %x to i8*
+  store i8 -2, i8* %a, align 1
+  %b = inttoptr i64 %x to i1*
+  store i1 true, i1* %b, align 1
+  ret void
+}
+define void @pr43446_1(i8* %a) {
+; CHECK-LABEL: pr43446_1:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movb $-1, (%rdi)
+; CHECK-NEXT:    retq
+  store i8 -2, i8* %a, align 1
+  %b = bitcast i8* %a to i1*
+  store i1 true, i1* %b, align 1
+  ret void
+}