Skip to content

LLVM miscompiles some vector instructions for MIPS #3317

@LemonBoy

Description

@LemonBoy

EDIT:: Here are the reduced and failing test cases.

; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "foo"
target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
target triple = "mipsel-unknown-linux-none"

define dso_local fastcc void @hash(<4 x i9>) unnamed_addr #0 {
Entry:
  store <4 x i9> %0, <4 x i9>* undef, align 8
  unreachable
}

attributes #0 = { "no-frame-pointer-elim-non-leaf" }

!llvm.module.flags = !{!0}

!0 = !{i32 2, !"Dwarf Version", i32 4}
; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "foo"
target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
target triple = "mipsel-unknown-linux-none"

; Function Attrs: nobuiltin nounwind
define void @entry() #0 {
Entry:
  %a = alloca <3 x i9>, align 8
  store <3 x i9> <i9 8, i9 16, i9 24>, <3 x i9>* %a, align 8
  %0 = load <3 x i9>, <3 x i9>* %a, align 8
  call fastcc void @hash(<3 x i9> %0)
  ret void
}

; Function Attrs: nobuiltin nounwind
define internal fastcc void @hash(<3 x i9>) unnamed_addr #0 {
Entry:
  %array = alloca [3 x i9], align 2
  %x = alloca <3 x i9>, align 8
  store <3 x i9> %0, <3 x i9>* %x, align 8
  %1 = load <3 x i9>, <3 x i9>* %x, align 8
  %2 = getelementptr inbounds [3 x i9], [3 x i9]* %array, i32 0, i32 0
  %3 = extractelement <3 x i9> %1, i32 0
  store i9 %3, i9* %2
  %4 = getelementptr inbounds [3 x i9], [3 x i9]* %array, i32 0, i32 1
  %5 = extractelement <3 x i9> %1, i32 1
  store i9 %5, i9* %4
  %6 = getelementptr inbounds [3 x i9], [3 x i9]* %array, i32 0, i32 2
  %7 = extractelement <3 x i9> %1, i32 2
  store i9 %7, i9* %6
  %8 = getelementptr inbounds [3 x i9], [3 x i9]* %array, i32 0, i32 0
  %9 = load i9, i9* %8, align 2
  %10 = icmp ne i9 %9, 8
  br i1 %10, label %Then, label %Else

Then:                                             ; preds = %Entry
  call void @llvm.debugtrap()
  br label %EndIf

Else:                                             ; preds = %Entry
  br label %EndIf

EndIf:                                            ; preds = %Else, %Then
  %11 = getelementptr inbounds [3 x i9], [3 x i9]* %array, i32 0, i32 1
  %12 = load i9, i9* %11, align 2
  %13 = icmp ne i9 %12, 16
  br i1 %13, label %Then1, label %Else2

Then1:                                            ; preds = %EndIf
  call void @llvm.debugtrap()
  br label %EndIf3

Else2:                                            ; preds = %EndIf
  br label %EndIf3

EndIf3:                                           ; preds = %Else2, %Then1
  %14 = getelementptr inbounds [3 x i9], [3 x i9]* %array, i32 0, i32 2
  %15 = load i9, i9* %14, align 2
  %16 = icmp ne i9 %15, 24
  br i1 %16, label %Then4, label %Else5

Then4:                                            ; preds = %EndIf3
  call void @llvm.debugtrap()
  br label %EndIf6

Else5:                                            ; preds = %EndIf3
  br label %EndIf6

EndIf6:                                           ; preds = %Else5, %Then4
  ret void
}

; Function Attrs: nounwind
declare void @llvm.debugtrap() #1

attributes #0 = { nobuiltin nounwind "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
attributes #1 = { nounwind }

!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 2, !"Dwarf Version", i32 4}
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "zig 0.5.0", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !4)
!3 = !DIFile(filename: "foo", directory: "/tmp")
!4 = !{}

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-mips32-bit MIPSbugObserved behavior contradicts documented or intended behaviorupstreamAn issue with a third party project that Zig uses.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions