1cee313d2SEric Christopher; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S -enable-if-conversion | FileCheck %s 2cee313d2SEric Christopher 3cee313d2SEric Christophertarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 4cee313d2SEric Christopher 5cee313d2SEric Christopher;CHECK: fc 6cee313d2SEric Christopher;CHECK: load <4 x i16> 7cee313d2SEric Christopher;CHECK-NEXT: shufflevector <4 x i16> 8cee313d2SEric Christopher;CHECK: select <4 x i1> 9cee313d2SEric Christopher;CHECK: store <4 x i16> 10cee313d2SEric Christopher;CHECK: ret 11cee313d2SEric Christopherdefine void @fc(i16* nocapture %p, i32 %n, i32 %size) nounwind uwtable ssp { 12cee313d2SEric Christopherentry: 13cee313d2SEric Christopher br label %do.body 14cee313d2SEric Christopher 15cee313d2SEric Christopherdo.body: ; preds = %cond.end, %entry 16cee313d2SEric Christopher %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %cond.end ] 17cee313d2SEric Christopher %p.addr.0 = phi i16* [ %p, %entry ], [ %incdec.ptr, %cond.end ] 18cee313d2SEric Christopher %incdec.ptr = getelementptr inbounds i16, i16* %p.addr.0, i64 -1 19cee313d2SEric Christopher %0 = load i16, i16* %incdec.ptr, align 2 20cee313d2SEric Christopher %conv = zext i16 %0 to i32 21cee313d2SEric Christopher %cmp = icmp ult i32 %conv, %size 22cee313d2SEric Christopher br i1 %cmp, label %cond.end, label %cond.true 23cee313d2SEric Christopher 24cee313d2SEric Christophercond.true: ; preds = %do.body 25cee313d2SEric Christopher %sub = sub i32 %conv, %size 26cee313d2SEric Christopher %phitmp = trunc i32 %sub to i16 27cee313d2SEric Christopher br label %cond.end 28cee313d2SEric Christopher 29cee313d2SEric Christophercond.end: ; preds = %do.body, %cond.true 30cee313d2SEric Christopher %cond = phi i16 [ %phitmp, %cond.true ], [ 0, %do.body ] 31cee313d2SEric Christopher store i16 %cond, i16* %incdec.ptr, align 2 32cee313d2SEric Christopher %dec = add i32 %n.addr.0, -1 33cee313d2SEric Christopher %tobool = icmp eq i32 %dec, 0 34cee313d2SEric Christopher br i1 %tobool, label %do.end, label %do.body 35cee313d2SEric Christopher 36cee313d2SEric Christopherdo.end: ; preds = %cond.end 37cee313d2SEric Christopher ret void 38cee313d2SEric Christopher} 39cee313d2SEric Christopher 40cee313d2SEric Christopher;CHECK: example1 41cee313d2SEric Christopher;CHECK: load <4 x i32> 42cee313d2SEric Christopher;CHECK-NEXT: shufflevector <4 x i32> 43*b48fe158SSanjay Patel;CHECK: sub nsw <4 x i32> 44*b48fe158SSanjay Patel;CHECK: select <4 x i1> 45cee313d2SEric Christopher;CHECK: store <4 x i32> 46cee313d2SEric Christopher;CHECK: ret 47cee313d2SEric Christopherdefine void @example1(i32* nocapture %a, i32 %n, i32 %wsize) nounwind uwtable ssp { 48cee313d2SEric Christopherentry: 49cee313d2SEric Christopher br label %do.body 50cee313d2SEric Christopher 51cee313d2SEric Christopherdo.body: ; preds = %do.body, %entry 52cee313d2SEric Christopher %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %do.body ] 53cee313d2SEric Christopher %p.0 = phi i32* [ %a, %entry ], [ %incdec.ptr, %do.body ] 54cee313d2SEric Christopher %incdec.ptr = getelementptr inbounds i32, i32* %p.0, i64 -1 55cee313d2SEric Christopher %0 = load i32, i32* %incdec.ptr, align 4 56cee313d2SEric Christopher %cmp = icmp slt i32 %0, %wsize 57cee313d2SEric Christopher %sub = sub nsw i32 %0, %wsize 58cee313d2SEric Christopher %cond = select i1 %cmp, i32 0, i32 %sub 59cee313d2SEric Christopher store i32 %cond, i32* %incdec.ptr, align 4 60cee313d2SEric Christopher %dec = add nsw i32 %n.addr.0, -1 61cee313d2SEric Christopher %tobool = icmp eq i32 %dec, 0 62cee313d2SEric Christopher br i1 %tobool, label %do.end, label %do.body 63cee313d2SEric Christopher 64cee313d2SEric Christopherdo.end: ; preds = %do.body 65cee313d2SEric Christopher ret void 66cee313d2SEric Christopher} 67