[InstCombine] Call simplifyLoadInst()
InstCombine is supposed to be a superset of InstSimplify, but failed to invoke load simplification. Unfortunately, this causes a minor compile-time regression, which will be mitigated in a future commit.
This commit is contained in:
parent
9196908bc2
commit
be88b5814d
|
@ -318,6 +318,10 @@ Value *simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q);
|
|||
/// If not, this returns null.
|
||||
Value *simplifyFreezeInst(Value *Op, const SimplifyQuery &Q);
|
||||
|
||||
/// Given a load instruction and its pointer operand, fold the result or return
|
||||
/// null.
|
||||
Value *simplifyLoadInst(LoadInst *LI, Value *PtrOp, const SimplifyQuery &Q);
|
||||
|
||||
/// See if we can compute a simplified version of this instruction. If not,
|
||||
/// return null.
|
||||
Value *simplifyInstruction(Instruction *I, const SimplifyQuery &Q,
|
||||
|
|
|
@ -6590,8 +6590,8 @@ Value *llvm::simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) {
|
|||
return ::simplifyFreezeInst(Op0, Q);
|
||||
}
|
||||
|
||||
static Value *simplifyLoadInst(LoadInst *LI, Value *PtrOp,
|
||||
const SimplifyQuery &Q) {
|
||||
Value *llvm::simplifyLoadInst(LoadInst *LI, Value *PtrOp,
|
||||
const SimplifyQuery &Q) {
|
||||
if (LI->isVolatile())
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -1024,6 +1024,8 @@ static bool canSimplifyNullLoadOrGEP(LoadInst &LI, Value *Op) {
|
|||
|
||||
Instruction *InstCombinerImpl::visitLoadInst(LoadInst &LI) {
|
||||
Value *Op = LI.getOperand(0);
|
||||
if (Value *Res = simplifyLoadInst(&LI, Op, SQ.getWithInstruction(&LI)))
|
||||
return replaceInstUsesWith(LI, Res);
|
||||
|
||||
// Try to canonicalize the loaded type.
|
||||
if (Instruction *Res = combineLoadToOperationType(*this, LI))
|
||||
|
|
|
@ -395,9 +395,7 @@ define <2 x i64> @test24(ptr %P) {
|
|||
|
||||
define i16 @load_from_zero_with_dynamic_offset(i64 %idx) {
|
||||
; CHECK-LABEL: @load_from_zero_with_dynamic_offset(
|
||||
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i16, ptr @GLOBAL, i64 [[IDX:%.*]]
|
||||
; CHECK-NEXT: [[V:%.*]] = load i16, ptr [[GEP]], align 2
|
||||
; CHECK-NEXT: ret i16 [[V]]
|
||||
; CHECK-NEXT: ret i16 0
|
||||
;
|
||||
%gep = getelementptr i16, ptr @GLOBAL, i64 %idx
|
||||
%v = load i16, ptr %gep
|
||||
|
@ -408,10 +406,7 @@ declare ptr @llvm.strip.invariant.group.p0(ptr %p)
|
|||
|
||||
define i32 @load_via_strip_invariant_group() {
|
||||
; CHECK-LABEL: @load_via_strip_invariant_group(
|
||||
; CHECK-NEXT: [[A:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr nonnull @Y)
|
||||
; CHECK-NEXT: [[B:%.*]] = getelementptr i8, ptr [[A]], i64 8
|
||||
; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[B]], align 4
|
||||
; CHECK-NEXT: ret i32 [[D]]
|
||||
; CHECK-NEXT: ret i32 37
|
||||
;
|
||||
%a = call ptr @llvm.strip.invariant.group.p0(ptr @Y)
|
||||
%b = getelementptr i8, ptr %a, i64 8
|
||||
|
|
|
@ -303,9 +303,7 @@ entry:
|
|||
define float @test11(i64 %i) {
|
||||
; CHECK-LABEL: @test11(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[G:%.*]] = getelementptr [4 x float], ptr addrspace(1) @I, i64 0, i64 [[I:%.*]]
|
||||
; CHECK-NEXT: [[R:%.*]] = load float, ptr addrspace(1) [[G]], align 4
|
||||
; CHECK-NEXT: ret float [[R]]
|
||||
; CHECK-NEXT: ret float 0.000000e+00
|
||||
;
|
||||
|
||||
entry:
|
||||
|
|
Loading…
Reference in New Issue
Block a user