| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 6 | |
| ; RUN: opt -S -passes=loop-vectorize < %s | FileCheck %s | |
| target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" | |
| target triple = "i686-pc-windows-msvc18.0.0" | |
| @sink = external global double | |
| ; Operand bundles are not modeled by the vectorizer, so loops with calls with | |
| ; funclet operand bundles are not vectorized. | |
| define void @test1(ptr %p) #0 personality ptr @__CxxFrameHandler3 { | |
| ; CHECK-LABEL: define void @test1( | |
| ; CHECK-SAME: ptr [[P:%.*]]) #[[ATTR0:[0-9]+]] personality ptr @__CxxFrameHandler3 { | |
| ; CHECK-NEXT: [[ENTRY:.*:]] | |
| ; CHECK-NEXT: invoke void @_CxxThrowException(ptr null, ptr null) | |
| ; CHECK-NEXT: to label %[[UNREACHABLE:.*]] unwind label %[[CATCH_DISPATCH:.*]] | |
| ; CHECK: [[CATCH_DISPATCH]]: | |
| ; CHECK-NEXT: [[TMP0:%.*]] = catchswitch within none [label %[[CATCH:.*]]] unwind to caller | |
| ; CHECK: [[CATCH]]: | |
| ; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[TMP0]] [ptr null, i32 64, ptr null] | |
| ; CHECK-NEXT: br label %[[LOOP:.*]] | |
| ; CHECK: [[LOOP]]: | |
| ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, %[[CATCH]] ], [ [[INC:%.*]], %[[LOOP]] ] | |
| ; CHECK-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[P]], i32 [[IV]] | |
| ; CHECK-NEXT: [[X:%.*]] = load double, ptr [[GEP]], align 8 | |
| ; CHECK-NEXT: [[CALL:%.*]] = call double @floor(double [[X]]) #[[ATTR1:[0-9]+]] [ "funclet"(token [[TMP1]]) ] | |
| ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[IV]], 1 | |
| ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], 1024 | |
| ; CHECK-NEXT: br i1 [[EXITCOND]], label %[[EXIT:.*]], label %[[LOOP]] | |
| ; CHECK: [[EXIT]]: | |
| ; CHECK-NEXT: [[CALL_LCSSA:%.*]] = phi double [ [[CALL]], %[[LOOP]] ] | |
| ; CHECK-NEXT: store double [[CALL_LCSSA]], ptr @sink, align 8 | |
| ; CHECK-NEXT: catchret from [[TMP1]] to label %[[TRY_CONT:.*]] | |
| ; CHECK: [[TRY_CONT]]: | |
| ; CHECK-NEXT: ret void | |
| ; CHECK: [[UNREACHABLE]]: | |
| ; CHECK-NEXT: unreachable | |
| ; | |
| entry: | |
| invoke void @_CxxThrowException(ptr null, ptr null) | |
| to label %unreachable unwind label %catch.dispatch | |
| catch.dispatch: | |
| %0 = catchswitch within none [label %catch] unwind to caller | |
| catch: | |
| %1 = catchpad within %0 [ptr null, i32 64, ptr null] | |
| br label %loop | |
| loop: | |
| %iv = phi i32 [ 0, %catch ], [ %inc, %loop ] | |
| %gep = getelementptr double, ptr %p, i32 %iv | |
| %x = load double, ptr %gep | |
| %call = call double @floor(double %x) #1 [ "funclet"(token %1) ] | |
| %inc = add nuw nsw i32 %iv, 1 | |
| %exitcond = icmp eq i32 %inc, 1024 | |
| br i1 %exitcond, label %exit, label %loop | |
| exit: | |
| store double %call, ptr @sink | |
| catchret from %1 to label %try.cont | |
| try.cont: | |
| ret void | |
| unreachable: | |
| unreachable | |
| } | |
| define void @constant_foldable() #0 personality ptr @__CxxFrameHandler3 { | |
| ; CHECK-LABEL: define void @constant_foldable( | |
| ; CHECK-SAME: ) #[[ATTR0]] personality ptr @__CxxFrameHandler3 { | |
| ; CHECK-NEXT: [[ENTRY:.*:]] | |
| ; CHECK-NEXT: invoke void @_CxxThrowException(ptr null, ptr null) | |
| ; CHECK-NEXT: to label %[[UNREACHABLE:.*]] unwind label %[[CATCH_DISPATCH:.*]] | |
| ; CHECK: [[CATCH_DISPATCH]]: | |
| ; CHECK-NEXT: [[TMP0:%.*]] = catchswitch within none [label %[[CATCH:.*]]] unwind to caller | |
| ; CHECK: [[CATCH]]: | |
| ; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[TMP0]] [ptr null, i32 64, ptr null] | |
| ; CHECK-NEXT: br label %[[LOOP:.*]] | |
| ; CHECK: [[LOOP]]: | |
| ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, %[[CATCH]] ], [ [[INC:%.*]], %[[LOOP]] ] | |
| ; CHECK-NEXT: [[CALL:%.*]] = call double @floor(double 1.000000e+00) #[[ATTR1]] [ "funclet"(token [[TMP1]]) ] | |
| ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[IV]], 1 | |
| ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], 1024 | |
| ; CHECK-NEXT: br i1 [[EXITCOND]], label %[[EXIT:.*]], label %[[LOOP]] | |
| ; CHECK: [[EXIT]]: | |
| ; CHECK-NEXT: [[CALL_LCSSA:%.*]] = phi double [ [[CALL]], %[[LOOP]] ] | |
| ; CHECK-NEXT: store double [[CALL_LCSSA]], ptr @sink, align 8 | |
| ; CHECK-NEXT: catchret from [[TMP1]] to label %[[TRY_CONT:.*]] | |
| ; CHECK: [[TRY_CONT]]: | |
| ; CHECK-NEXT: ret void | |
| ; CHECK: [[UNREACHABLE]]: | |
| ; CHECK-NEXT: unreachable | |
| ; | |
| entry: | |
| invoke void @_CxxThrowException(ptr null, ptr null) | |
| to label %unreachable unwind label %catch.dispatch | |
| catch.dispatch: | |
| %0 = catchswitch within none [label %catch] unwind to caller | |
| catch: | |
| %1 = catchpad within %0 [ptr null, i32 64, ptr null] | |
| br label %loop | |
| loop: | |
| %iv = phi i32 [ 0, %catch ], [ %inc, %loop ] | |
| %call = call double @floor(double 1.0) #1 [ "funclet"(token %1) ] | |
| %inc = add nuw nsw i32 %iv, 1 | |
| %exitcond = icmp eq i32 %inc, 1024 | |
| br i1 %exitcond, label %exit, label %loop | |
| exit: | |
| store double %call, ptr @sink | |
| catchret from %1 to label %try.cont | |
| try.cont: | |
| ret void | |
| unreachable: | |
| unreachable | |
| } | |
| declare x86_stdcallcc void @_CxxThrowException(ptr, ptr) | |
| declare i32 @__CxxFrameHandler3(...) | |
| declare double @floor(double) #1 | |
| attributes #0 = { "target-features"="+sse2" } | |
| attributes #1 = { nounwind readnone } |