Index: lib/AST/Stmt.cpp =================================================================== --- lib/AST/Stmt.cpp +++ lib/AST/Stmt.cpp @@ -632,6 +632,14 @@ CurPtr = NameEnd+1; continue; + } else if (*Begin == 'v') { + // GCC accepts code staring with "%v", e. g. "%vpcmpestri" and transforms + // it into "vpcmpestri" instruction if target processor supports AVX and + // into "pcmpestri" otherwise. + if (C.getTargetInfo().hasFeature("avx")) + CurStringPiece = "v" + CurStringPiece; + CurStringPiece += EscapedChar; + continue; } DiagOffs = CurPtr-StrStart-1; Index: test/CodeGen/avx-inline-asm.c =================================================================== --- test/CodeGen/avx-inline-asm.c +++ test/CodeGen/avx-inline-asm.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux -target-feature +avx -emit-llvm -S %s -o - | FileCheck %s -check-prefix=CHECK-AVX +// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm -S %s -o - | FileCheck %s + +void f(void* arg) +{ + __asm__ ("%vpcmpestri $0, (%1), %2" + : "=c"(arg) + : "r"(arg), "x"(arg)); + + // CHECK: pcmpestri + // CHECK-AVX: vpcmpestri +}