40 lines · plain
1; RUN: opt -S -passes=gvn -enable-load-pre < %s | FileCheck %s2;3; The partially redundant load in bb1 should be hoisted to "bb". This comes4; from this C code (GCC PR 23455):5; unsigned outcnt; extern void flush_outbuf(void);6; void bi_windup(unsigned char *outbuf, unsigned char bi_buf) {7; outbuf[outcnt] = bi_buf;8; if (outcnt == 16384)9; flush_outbuf();10; outbuf[outcnt] = bi_buf;11; }12target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"13@outcnt = common global i32 0 ; <ptr> [#uses=3]14 15define void @bi_windup(ptr %outbuf, i8 zeroext %bi_buf) nounwind {16entry:17 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]18 %0 = load i32, ptr @outcnt, align 4 ; <i32> [#uses=1]19 %1 = getelementptr i8, ptr %outbuf, i32 %0 ; <ptr> [#uses=1]20 store i8 %bi_buf, ptr %1, align 121 %2 = load i32, ptr @outcnt, align 4 ; <i32> [#uses=1]22 %3 = icmp eq i32 %2, 16384 ; <i1> [#uses=1]23 br i1 %3, label %bb, label %bb124 25bb: ; preds = %entry26 call void @flush_outbuf() nounwind27 br label %bb128 29bb1: ; preds = %bb, %entry30; CHECK: bb1:31; CHECK-NEXT: phi32; CHECK-NEXT: getelementptr33 %4 = load i32, ptr @outcnt, align 4 ; <i32> [#uses=1]34 %5 = getelementptr i8, ptr %outbuf, i32 %4 ; <ptr> [#uses=1]35 store i8 %bi_buf, ptr %5, align 136 ret void37}38 39declare void @flush_outbuf()40