miscompile: miscompile rv64: add,addi,andi,beq,beqz,bge

Run:explore-db12fc36f6-20261127-115111
Kind:miscompile
Category:miscompile rv64: add,addi,andi,beq,beqz,bge M
Occurrences:1 in 1 configs, 1 test files
Snippet from:pr139075.6465d626.1a71daf8.270f02b1.186cd17e83.ll (mutant of pr139075.6465d626.1a71daf8.270f02b1.ll) @a via llvm-extract
Config:-mtriple=riscv64 -verify-machineinstrs -mattr=+v,+zvl16384b,+zfa,+zvkb,+zbb -O1
Local check:reproduces at db12fc36f6
Compiler Explorer:not applicable: Compiler Explorer compiles RISC-V but cannot run it

Snippet:

@G.1 = external global ptr
@G.3 = external global i1
@G.4 = external global float
@G.5 = external global i1
@G.6 = external global ptr
@G.7 = external global i128
@G.8 = external global ptr
@G.9 = external global i1
@G.10 = external global <4 x i32>
@G.11 = external global i64
@G.13 = external global i1

define void @a(ptr %0, ptr %1) {
  %A15 = alloca i16, align 2
  store i16 -1, ptr %A15, align 2
  %A6 = alloca i8, align 1
  store i8 -1, ptr %A6, align 1
  %A4 = alloca ptr, align 8
  store ptr poison, ptr %A4, align 8
  %LGV5 = load i128, ptr @G.7, align 4
  %LGV1 = load float, ptr @G.4, align 4
  %A10 = alloca i1, align 1
  %I = insertelement <4 x i32> zeroinitializer, i32 0, i64 0
  store i1 true, ptr %A10, align 1
  %G10 = getelementptr i128, ptr %0, i32 0
  %G4 = getelementptr inbounds ptr, ptr %1, i1 false
  store <4 x i32> %I, ptr @G.10, align 16
  %C8 = fcmp oeq float +inf, 1.000000e+00
  store ptr %G4, ptr @G.6, align 8
  store i1 %C8, ptr @G.3, align 1
  %A = alloca i1, align 1
  %G = getelementptr half, ptr %0, i1 true
  %C2 = fcmp ueq float 1.401300e-45, %LGV1
  %L9 = load i1, ptr %A, align 1
  %L3 = load i64, ptr %G, align 4
  %C = icmp ule i64 %L3, 9223372036854775807
  store ptr %G, ptr @G.1, align 8
  %L = load i128, ptr %G4, align 4
  store ptr %G10, ptr @G.8, align 8
  %L1 = load i8, ptr %G4, align 1
  %C6 = icmp sle i128 %L, %LGV5
  store i1 %C, ptr @G.9, align 1
  store i1 %C6, ptr @G.3, align 1
  store i1 %C2, ptr @G.5, align 1
  store i1 false, ptr %A, align 1
  %G2 = getelementptr ptr, ptr %G4, i8 %L1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %G2, ptr align 4 %1, i64 2048, i1 false)
  br i1 %L9, label %T, label %F

BB:                                               ; preds = %F, %BB14
  %L7 = load i8, ptr %A6, align 1
  switch i8 %L7, label %SW_D [
    i8 -110, label %SW_C
    i8 95, label %SW_C8
    i8 57, label %SW_C9
    i8 34, label %SW_C10
    i8 52, label %SW_C11
  ]

BB5:                                              ; preds = %SW_C8
  %G1 = getelementptr i1, ptr %G4, i16 -1
  store ptr %G1, ptr %G13, align 8
  ret void

T:                                                ; preds = %2
  %L16 = load i16, ptr %A15, align 2
  switch i16 %L16, label %SW_D17 [
    i16 30189, label %SW_C18
    i16 2675, label %SW_C19
    i16 25683, label %SW_C20
    i16 5714, label %SW_C21
    i16 -29524, label %SW_C22
    i16 -22813, label %SW_C23
    i16 -20346, label %SW_C24
  ]

BB14:                                             ; preds = %SW_C24, %SW_C22, %SW_C19, %SW_D17
  %B = udiv i64 0, %L3
  store i64 %B, ptr @G.11, align 4
  br label %BB

F:                                                ; preds = %F, %2
  %L11 = load i1, ptr %A10, align 1
  %G3 = getelementptr i8, ptr %0, i128 %LGV5
  store ptr %G3, ptr %A4, align 8
  br i1 %L11, label %BB, label %F

SW_D:                                             ; preds = %BB
  ret void

SW_C:                                             ; preds = %BB
  ret void

SW_C8:                                            ; preds = %BB
  %G13 = getelementptr i16, ptr %G4, i16 256
  br label %BB5

SW_C9:                                            ; preds = %BB
  ret void

SW_C10:                                           ; preds = %BB
  ret void

SW_C11:                                           ; preds = %BB
  ret void

SW_D17:                                           ; preds = %T
  br label %BB14

SW_C18:                                           ; preds = %T
  ret void

SW_C19:                                           ; preds = %T
  br label %BB14

SW_C20:                                           ; preds = %T
  ret void

SW_C21:                                           ; preds = %T
  ret void

SW_C22:                                           ; preds = %SW_C22, %T
  %LGV = load i1, ptr @G.13, align 1
  br i1 %LGV, label %SW_C22, label %BB14

SW_C23:                                           ; preds = %T
  ret void

SW_C24:                                           ; preds = %SW_C24, %T
  br i1 %C8, label %BB14, label %SW_C24
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }

Reproduce:

./exec_oracle.py --flags '-mtriple=riscv64 -verify-machineinstrs -mattr=+v,+zvl16384b,+zfa,+zvkb,+zbb -O1' --funcs a snippet.ll

Local execution result:

60 of 64 inputs differ (first: #0)
SelectionDAG hash 8243eb11b626a602, GlobalISel hash cf4ddca84a9f9953
b0: llc -mtriple=riscv64 -verify-machineinstrs -mattr=+v,+zvl16384b,+zfa,+zvkb,+zbb -O1 -global-isel=0
b1: llc -mtriple=riscv64 -verify-machineinstrs -mattr=+v,+zvl16384b,+zfa,+zvkb,+zbb -O0 -global-isel=0
b2: llc -mtriple=riscv64 -verify-machineinstrs -mattr=+v,+zvl16384b,+zfa,+zvkb,+zbb -O1 -global-isel -global-isel-abort=2

Occurrences (1):

InputFunctionConfig
pr139075.6465d626.1a71daf8.270f02b1.186cd17e83.ll (mutant of pr139075.6465d626.1a71daf8.270f02b1.ll)a-mtriple=riscv64 -verify-machineinstrs -mattr=+v,+zvl16384b,+zfa,+zvkb,+zbb -O1

Generated 2026-11-29 14:49 UTC.