miscompile: miscompile rv64: addi,and,andi,beqz,bnez,fcvt.w.d

Run:explore-b577f07195-20261129-105236
Kind:miscompile
Category:miscompile rv64: addi,and,andi,beqz,bnez,fcvt.w.d NEW M
Occurrences:1 in 1 configs, 1 test files
Snippet from:double-round-conv.547dac36.6764b4e3.70c66375.0659821c66.ll (mutant of double-round-conv.547dac36.6764b4e3.70c66375.ll) @test_trunc_si16 via llvm-extract
Config:-mtriple=riscv64 -verify-machineinstrs -target-abi=lp64d -mattr=+d,+m,+zve64d -O1
Local check:reproduces at b577f07195
Compiler Explorer:not applicable: Compiler Explorer compiles RISC-V but cannot run it

Snippet:

@G = external global double
@G.1 = external global i1
@G.5 = external global <4 x i32>
@G.7 = external global i1
@G.8 = external global i16
@G.9 = external global i128

define signext i16 @test_trunc_si16(double %x) {
  %A15 = alloca i1, align 1
  store i1 false, ptr %A15, align 1
  %A13 = alloca i1, align 1
  store i1 true, ptr %A13, align 1
  %A7 = alloca i128, align 8
  store i128 -170141183460469231731687303715884105728, ptr %A7, align 4
  %LGV4 = load i1, ptr @G.7, align 1
  %A = alloca i1, align 1
  br i1 %LGV4, label %T2, label %F3

BB1:                                              ; preds = %F3
  store i1 true, ptr %A, align 1
  %LGV = load double, ptr @G, align 8
  %a = call double @llvm.trunc.f64(double %x)
  %b = fptosi double %a to i16
  %C = fcmp uno double %a, %LGV
  %B = lshr <4 x i32> splat (i32 -1), splat (i32 -2147483648)
  %C1 = fcmp ule double %x, %x
  store i1 %C, ptr @G.1, align 1
  %L = load i1, ptr %A, align 1
  br i1 %L, label %T, label %F

BB:                                               ; preds = %F, %BB6
  store i1 %C1, ptr @G.1, align 1
  store <4 x i32> %B, ptr @G.5, align 16
  ret i16 %b

T:                                                ; preds = %BB1
  %L8 = load i128, ptr %A7, align 4
  switch i128 %L8, label %SW_D [
    i128 13451350815448641828, label %SW_C
    i128 15325778800100832966, label %SW_C9
    i128 14243757703288132181, label %SW_C10
    i128 745135183658623364, label %SW_C11
    i128 5957567228890268753, label %SW_C12
  ]

BB6:                                              ; preds = %SW_C11, %SW_C10, %SW_C9, %SW_C, %SW_D
  br label %BB

F:                                                ; preds = %BB1
  br label %BB

T2:                                               ; preds = %0
  %LGV18 = load i128, ptr @G.9, align 4
  %LGV5 = load i16, ptr @G.8, align 2
  %B19 = and i128 1, %LGV18
  store i128 %B19, ptr @G.9, align 4
  ret i16 %LGV5

F3:                                               ; preds = %0
  br label %BB1

SW_D:                                             ; preds = %T
  br label %BB6

SW_C:                                             ; preds = %T
  br label %BB6

SW_C9:                                            ; preds = %SW_C9, %T
  %L14 = load i1, ptr %A13, align 1
  br i1 %L14, label %SW_C9, label %BB6

SW_C10:                                           ; preds = %SW_C10, %T
  %L16 = load i1, ptr %A15, align 1
  br i1 %L16, label %BB6, label %SW_C10

SW_C11:                                           ; preds = %T
  br label %BB6

SW_C12:                                           ; preds = %T
  ret i16 %b
}

; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.trunc.f64(double) #0

attributes #0 = { nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none) }

Reproduce:

./exec_oracle.py --flags '-mtriple=riscv64 -verify-machineinstrs -target-abi=lp64d -mattr=+d,+m,+zve64d -O1' --funcs test_trunc_si16 snippet.ll

Local execution result:

3 of 64 inputs differ (first: #12)
SelectionDAG hash 35a83a8c39022ab9, GlobalISel hash 4a0c640c306e95b7
b0: llc -mtriple=riscv64 -verify-machineinstrs -target-abi=lp64d -mattr=+d,+m,+zve64d -O1 -global-isel=0
b1: llc -mtriple=riscv64 -verify-machineinstrs -target-abi=lp64d -mattr=+d,+m,+zve64d -O0 -global-isel=0
b2: llc -mtriple=riscv64 -verify-machineinstrs -target-abi=lp64d -mattr=+d,+m,+zve64d -O1 -global-isel -global-isel-abort=2

Occurrences (1):

InputFunctionConfig
double-round-conv.547dac36.6764b4e3.70c66375.0659821c66.ll (mutant of double-round-conv.547dac36.6764b4e3.70c66375.ll)test_trunc_si16-mtriple=riscv64 -verify-machineinstrs -target-abi=lp64d -mattr=+d,+m,+zve64d -O1

Generated 2026-11-29 14:49 UTC.