
When calling SimplifyDemandedBits (as opposed to SimplifyDemandedInstructionBits), and there are multiple uses, always use SimplifyMultipleUseDemandedBits and drop the special case for root values. This fixes the ephemeral value detection, as seen by the restored assumes in tests. It may result in more or less simplification, depending on whether we get more out of having demanded bits or the ability to perform non-multi-use transforms. The change in the phi-known-bits.ll test is because the icmp operand now gets simplified based on demanded bits, which then prevents a different known bits simplification later. This also makes the code safe against future changes like https://github.com/llvm/llvm-project/pull/97289, which add more context that would have to be discarded for the multi-use case.
28 lines
1.0 KiB
LLVM
28 lines
1.0 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
; A copy of assume.ll, with undef at insertelement/shufflevector replaced with
|
|
; poison.
|
|
declare void @llvm.assume(i1) #1
|
|
|
|
; This would crash.
|
|
; Does it ever make sense to peek through a bitcast of the icmp operand?
|
|
|
|
define i32 @PR40940(<4 x i8> %x) {
|
|
; CHECK-LABEL: @PR40940(
|
|
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
|
|
; CHECK-NEXT: [[T2:%.*]] = bitcast <4 x i8> [[SHUF]] to i32
|
|
; CHECK-NEXT: [[T3:%.*]] = icmp ult i32 [[T2]], 65536
|
|
; CHECK-NEXT: call void @llvm.assume(i1 [[T3]])
|
|
; CHECK-NEXT: ret i32 [[T2]]
|
|
;
|
|
%shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> <i32 1, i32 1, i32 2, i32 3>
|
|
%t2 = bitcast <4 x i8> %shuf to i32
|
|
%t3 = icmp ult i32 %t2, 65536
|
|
call void @llvm.assume(i1 %t3)
|
|
ret i32 %t2
|
|
}
|