// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s

// Don't include mm_malloc.h, it's system specific.
#define __MM_MALLOC_H
#include <immintrin.h>

int test_bit_scan_forward(int a) {
  return _bit_scan_forward(a);
// CHECK: @test_bit_scan_forward
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(
// CHECK: ret i32 %[[call]]
}

int test_bit_scan_reverse(int a) {
  return _bit_scan_reverse(a);
// CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(
// CHECK:  %[[sub:.*]] = sub nsw i32 31, %2
// CHECK: ret i32 %[[sub]]
}

// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s

// Don't include mm_malloc.h, it's system specific.
#define __MM_MALLOC_H
#include <immintrin.h>

int test_bit_scan_forward(int a) {
  return _bit_scan_forward(a);
// CHECK: @test_bit_scan_forward
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(
// CHECK: ret i32 %[[call]]
}

int test_bit_scan_reverse(int a) {
  return _bit_scan_reverse(a);
// CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(
// CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
// CHECK: ret i32 %[[sub]]
}

Test fix -- use captured call result instead of hardcoded %2.
Test fix -- use captured call result instead of hardcoded %2.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@272573 91177308-0d34-0410-b5e6-96231b3b80d8
