Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7443,6 +7443,10 @@ DB = &DB_; ORE = &ORE_; + // Do not vectorize functions when the target should be fuzzed. + if (F.hasFnAttribute(Attribute::OptForFuzzing)) + return false; + // Don't attempt if // 1. the target claims to have no vector registers, and // 2. interleaving won't help ILP. Index: test/Transforms/LoopVectorize/opt-for-fuzzing.ll =================================================================== --- /dev/null +++ test/Transforms/LoopVectorize/opt-for-fuzzing.ll @@ -0,0 +1,31 @@ +; RUN: opt < %s -loop-vectorize -S | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +; CHECK-NOT: vector.body + +define i8 @foo(i1 %c, i32 %x, i32 %n) optforfuzzing { +entry: + br label %for.body + +for.body: + %i = phi i32 [ 0, %entry ], [ %i.next, %if.end ] + %r = phi i32 [ 0, %entry ], [ %r.next, %if.end ] + br i1 %c, label %if.then, label %if.end + +if.then: + %tmp0 = sdiv i32 undef, undef + br label %if.end + +if.end: + %tmp1 = and i32 %r, 255 + %i.next = add nsw i32 %i, 1 + %r.next = add nuw nsw i32 %tmp1, %x + %cond = icmp eq i32 %i.next, %n + br i1 %cond, label %for.end, label %for.body + +for.end: + %tmp2 = phi i32 [ %r.next, %if.end ] + %tmp3 = trunc i32 %tmp2 to i8 + ret i8 %tmp3 +}