[llvm] [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (PR #104924)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 08:12:46 PDT 2024


https://github.com/dtcxzyw approved this pull request.

LGTM.

Another x86 reproducer:
```
; bin/llc reduced.ll

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@g_214 = external global i16
@g_278.2 = external global i16

define i32 @main() {
entry:
  %0 = load i16, ptr @g_214, align 2
  %1 = xor i16 %0, 1
  store i16 0, ptr @g_278.2, align 2
  %2 = insertelement <4 x i16> zeroinitializer, i16 %0, i64 0
  %3 = insertelement <4 x i16> %2, i16 %1, i64 1
  %4 = sext <4 x i16> %3 to <4 x i32>
  %5 = icmp sgt <4 x i32> %4, zeroinitializer
  %6 = load i16, ptr @g_214, align 2
  %7 = xor i16 %6, 1
  %8 = insertelement <8 x i16> zeroinitializer, i16 %7, i64 0
  %9 = sext <8 x i16> %8 to <8 x i32>
  %10 = icmp sgt <8 x i32> %9, zeroinitializer
  %11 = freeze <8 x i1> %10
  %12 = bitcast <8 x i1> %11 to i8
  %13 = icmp eq i8 %12, 0
  %14 = freeze <4 x i1> %5
  %15 = bitcast <4 x i1> %14 to i4
  %16 = icmp eq i4 %15, 0
  %op.rdx = and i1 %13, %16
  %and788.4.2.i = select i1 %op.rdx, i32 1, i32 0
  ret i32 %and788.4.2.i
}
```

https://github.com/llvm/llvm-project/pull/104924


More information about the llvm-commits mailing list