Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll
; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+bmi < %s | FileCheck %s --check-prefix=ALL --check-prefix=BMI | ; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+bmi < %s | FileCheck %s --check-prefix=ALL --check-prefix=BMI | ||||
; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+lzcnt < %s | FileCheck %s --check-prefix=ALL --check-prefix=LZCNT | ; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+lzcnt < %s | FileCheck %s --check-prefix=ALL --check-prefix=LZCNT | ||||
; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC | ; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC | ||||
define i64 @test1(i64 %A) { | define i64 @test1(i64 %A) { | ||||
; ALL-LABEL: @test1( | ; ALL-LABEL: @test1( | ||||
; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 | ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 | ||||
; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) | ; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) | ||||
; LZCNT-NEXT: select i1 [[COND]], i64 64, i64 [[CTLZ]] | ; ALL-NEXT: select i1 [[COND]], i64 64, i64 [[CTLZ]] | ||||
; BMI-NOT: select | |||||
; GENERIC-NOT: select | |||||
; ALL: ret | ; ALL: ret | ||||
entry: | entry: | ||||
%tobool = icmp eq i64 %A, 0 | %tobool = icmp eq i64 %A, 0 | ||||
br i1 %tobool, label %cond.end, label %cond.true | br i1 %tobool, label %cond.end, label %cond.true | ||||
cond.true: ; preds = %entry | cond.true: ; preds = %entry | ||||
%0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) | %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) | ||||
br label %cond.end | br label %cond.end | ||||
cond.end: ; preds = %entry, %cond.true | cond.end: ; preds = %entry, %cond.true | ||||
%cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] | %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] | ||||
ret i64 %cond | ret i64 %cond | ||||
} | } | ||||
define i32 @test2(i32 %A) { | define i32 @test2(i32 %A) { | ||||
; ALL-LABEL: @test2( | ; ALL-LABEL: @test2( | ||||
; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 | ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 | ||||
; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) | ; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) | ||||
; LZCNT-NEXT: select i1 [[COND]], i32 32, i32 [[CTLZ]] | ; ALL-NEXT: select i1 [[COND]], i32 32, i32 [[CTLZ]] | ||||
; BMI-NOT: select | |||||
; GENERIC-NOT: select | |||||
; ALL: ret | ; ALL: ret | ||||
entry: | entry: | ||||
%tobool = icmp eq i32 %A, 0 | %tobool = icmp eq i32 %A, 0 | ||||
br i1 %tobool, label %cond.end, label %cond.true | br i1 %tobool, label %cond.end, label %cond.true | ||||
cond.true: ; preds = %entry | cond.true: ; preds = %entry | ||||
%0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) | %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) | ||||
br label %cond.end | br label %cond.end | ||||
cond.end: ; preds = %entry, %cond.true | cond.end: ; preds = %entry, %cond.true | ||||
%cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] | %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] | ||||
ret i32 %cond | ret i32 %cond | ||||
} | } | ||||
define signext i16 @test3(i16 signext %A) { | define signext i16 @test3(i16 signext %A) { | ||||
; ALL-LABEL: @test3( | ; ALL-LABEL: @test3( | ||||
; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 | ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 | ||||
; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) | ; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) | ||||
; LZCNT-NEXT: select i1 [[COND]], i16 16, i16 [[CTLZ]] | ; ALL-NEXT: select i1 [[COND]], i16 16, i16 [[CTLZ]] | ||||
; BMI-NOT: select | |||||
; GENERIC-NOT: select | |||||
; ALL: ret | ; ALL: ret | ||||
entry: | entry: | ||||
%tobool = icmp eq i16 %A, 0 | %tobool = icmp eq i16 %A, 0 | ||||
br i1 %tobool, label %cond.end, label %cond.true | br i1 %tobool, label %cond.end, label %cond.true | ||||
cond.true: ; preds = %entry | cond.true: ; preds = %entry | ||||
%0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) | %0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) | ||||
br label %cond.end | br label %cond.end | ||||
cond.end: ; preds = %entry, %cond.true | cond.end: ; preds = %entry, %cond.true | ||||
%cond = phi i16 [ %0, %cond.true ], [ 16, %entry ] | %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ] | ||||
ret i16 %cond | ret i16 %cond | ||||
} | } | ||||
define i64 @test1b(i64 %A) { | define i64 @test1b(i64 %A) { | ||||
; ALL-LABEL: @test1b( | ; ALL-LABEL: @test1b( | ||||
; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 | ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 | ||||
; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) | ; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) | ||||
; BMI-NEXT: select i1 [[COND]], i64 64, i64 [[CTTZ]] | ; ALL-NEXT: select i1 [[COND]], i64 64, i64 [[CTTZ]] | ||||
; LZCNT-NOT: select | |||||
; GENERIC-NOT: select | |||||
; ALL: ret | ; ALL: ret | ||||
entry: | entry: | ||||
%tobool = icmp eq i64 %A, 0 | %tobool = icmp eq i64 %A, 0 | ||||
br i1 %tobool, label %cond.end, label %cond.true | br i1 %tobool, label %cond.end, label %cond.true | ||||
cond.true: ; preds = %entry | cond.true: ; preds = %entry | ||||
%0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) | %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) | ||||
br label %cond.end | br label %cond.end | ||||
cond.end: ; preds = %entry, %cond.true | cond.end: ; preds = %entry, %cond.true | ||||
%cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] | %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] | ||||
ret i64 %cond | ret i64 %cond | ||||
} | } | ||||
define i32 @test2b(i32 %A) { | define i32 @test2b(i32 %A) { | ||||
; ALL-LABEL: @test2b( | ; ALL-LABEL: @test2b( | ||||
; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 | ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 | ||||
; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) | ; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) | ||||
; BMI-NEXT: select i1 [[COND]], i32 32, i32 [[CTTZ]] | ; ALL-NEXT: select i1 [[COND]], i32 32, i32 [[CTTZ]] | ||||
; LZCNT-NOT: select | |||||
; GENERIC-NOT: select | |||||
; ALL: ret | ; ALL: ret | ||||
entry: | entry: | ||||
%tobool = icmp eq i32 %A, 0 | %tobool = icmp eq i32 %A, 0 | ||||
br i1 %tobool, label %cond.end, label %cond.true | br i1 %tobool, label %cond.end, label %cond.true | ||||
cond.true: ; preds = %entry | cond.true: ; preds = %entry | ||||
%0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) | %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) | ||||
br label %cond.end | br label %cond.end | ||||
cond.end: ; preds = %entry, %cond.true | cond.end: ; preds = %entry, %cond.true | ||||
%cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] | %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] | ||||
ret i32 %cond | ret i32 %cond | ||||
} | } | ||||
define signext i16 @test3b(i16 signext %A) { | define signext i16 @test3b(i16 signext %A) { | ||||
; ALL-LABEL: @test3b( | ; ALL-LABEL: @test3b( | ||||
; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 | ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 | ||||
; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) | ; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) | ||||
; BMI-NEXT: select i1 [[COND]], i16 16, i16 [[CTTZ]] | ; ALL-NEXT: select i1 [[COND]], i16 16, i16 [[CTTZ]] | ||||
; LZCNT-NOT: select | |||||
; GENERIC-NOT: select | |||||
; ALL: ret | ; ALL: ret | ||||
entry: | entry: | ||||
%tobool = icmp eq i16 %A, 0 | %tobool = icmp eq i16 %A, 0 | ||||
br i1 %tobool, label %cond.end, label %cond.true | br i1 %tobool, label %cond.end, label %cond.true | ||||
cond.true: ; preds = %entry | cond.true: ; preds = %entry | ||||
%0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) | %0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) | ||||
br label %cond.end | br label %cond.end | ||||
▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines |