fix a fairly serious oversight with switch formation from
or'd conditions. Previously we'd compile something like this:
int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}
into:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]
lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end
lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]
lor.rhs: ; preds = %entry
br label %lor.end
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
llvm-svn: 121671
2010-12-13 11:18:54 +08:00
|
|
|
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
2008-03-18 11:45:45 +08:00
|
|
|
|
|
|
|
declare void @foo1()
|
|
|
|
|
|
|
|
declare void @foo2()
|
|
|
|
|
|
|
|
define void @test1(i32 %V) {
|
|
|
|
%C1 = icmp eq i32 %V, 4 ; <i1> [#uses=1]
|
|
|
|
%C2 = icmp eq i32 %V, 17 ; <i1> [#uses=1]
|
|
|
|
%CN = or i1 %C1, %C2 ; <i1> [#uses=1]
|
|
|
|
br i1 %CN, label %T, label %F
|
|
|
|
T: ; preds = %0
|
|
|
|
call void @foo1( )
|
|
|
|
ret void
|
|
|
|
F: ; preds = %0
|
|
|
|
call void @foo2( )
|
|
|
|
ret void
|
fix a fairly serious oversight with switch formation from
or'd conditions. Previously we'd compile something like this:
int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}
into:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]
lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end
lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]
lor.rhs: ; preds = %entry
br label %lor.end
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
llvm-svn: 121671
2010-12-13 11:18:54 +08:00
|
|
|
; CHECK: @test1
|
|
|
|
; CHECK: switch i32 %V, label %F [
|
|
|
|
; CHECK: i32 17, label %T
|
|
|
|
; CHECK: i32 4, label %T
|
|
|
|
; CHECK: ]
|
2004-02-24 13:34:44 +08:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test2(i32 %V) {
|
|
|
|
%C1 = icmp ne i32 %V, 4 ; <i1> [#uses=1]
|
|
|
|
%C2 = icmp ne i32 %V, 17 ; <i1> [#uses=1]
|
|
|
|
%CN = and i1 %C1, %C2 ; <i1> [#uses=1]
|
|
|
|
br i1 %CN, label %T, label %F
|
|
|
|
T: ; preds = %0
|
|
|
|
call void @foo1( )
|
|
|
|
ret void
|
|
|
|
F: ; preds = %0
|
|
|
|
call void @foo2( )
|
|
|
|
ret void
|
fix a fairly serious oversight with switch formation from
or'd conditions. Previously we'd compile something like this:
int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}
into:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]
lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end
lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]
lor.rhs: ; preds = %entry
br label %lor.end
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
llvm-svn: 121671
2010-12-13 11:18:54 +08:00
|
|
|
; CHECK: @test2
|
|
|
|
; CHECK: switch i32 %V, label %T [
|
|
|
|
; CHECK: i32 17, label %F
|
|
|
|
; CHECK: i32 4, label %F
|
|
|
|
; CHECK: ]
|
2004-02-24 13:34:44 +08:00
|
|
|
}
|
|
|
|
|
2008-03-18 11:45:45 +08:00
|
|
|
define void @test3(i32 %V) {
|
|
|
|
%C1 = icmp eq i32 %V, 4 ; <i1> [#uses=1]
|
|
|
|
br i1 %C1, label %T, label %N
|
|
|
|
N: ; preds = %0
|
|
|
|
%C2 = icmp eq i32 %V, 17 ; <i1> [#uses=1]
|
|
|
|
br i1 %C2, label %T, label %F
|
|
|
|
T: ; preds = %N, %0
|
|
|
|
call void @foo1( )
|
|
|
|
ret void
|
|
|
|
F: ; preds = %N
|
|
|
|
call void @foo2( )
|
|
|
|
ret void
|
fix a fairly serious oversight with switch formation from
or'd conditions. Previously we'd compile something like this:
int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}
into:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]
lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end
lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]
lor.rhs: ; preds = %entry
br label %lor.end
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
llvm-svn: 121671
2010-12-13 11:18:54 +08:00
|
|
|
|
|
|
|
; CHECK: @test3
|
|
|
|
; CHECK: switch i32 %V, label %F [
|
|
|
|
; CHECK: i32 4, label %T
|
|
|
|
; CHECK: i32 17, label %T
|
|
|
|
; CHECK: ]
|
2005-02-24 10:13:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
fix a fairly serious oversight with switch formation from
or'd conditions. Previously we'd compile something like this:
int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}
into:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]
lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end
lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:
switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]
lor.rhs: ; preds = %entry
br label %lor.end
lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext
which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.
llvm-svn: 121671
2010-12-13 11:18:54 +08:00
|
|
|
|
|
|
|
define i32 @test4(i8 zeroext %c) nounwind ssp noredzone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp eq i8 %c, 62
|
|
|
|
br i1 %cmp, label %lor.end, label %lor.lhs.false
|
|
|
|
|
|
|
|
lor.lhs.false: ; preds = %entry
|
|
|
|
%cmp4 = icmp eq i8 %c, 34
|
|
|
|
br i1 %cmp4, label %lor.end, label %lor.rhs
|
|
|
|
|
|
|
|
lor.rhs: ; preds = %lor.lhs.false
|
|
|
|
%cmp8 = icmp eq i8 %c, 92
|
|
|
|
br label %lor.end
|
|
|
|
|
|
|
|
lor.end: ; preds = %lor.rhs, %lor.lhs.false, %entry
|
|
|
|
%0 = phi i1 [ true, %lor.lhs.false ], [ true, %entry ], [ %cmp8, %lor.rhs ]
|
|
|
|
%lor.ext = zext i1 %0 to i32
|
|
|
|
ret i32 %lor.ext
|
|
|
|
|
|
|
|
; CHECK: @test4
|
|
|
|
; CHECK: switch i8 %c, label %lor.rhs [
|
|
|
|
; CHECK: i8 62, label %lor.end
|
|
|
|
; CHECK: i8 34, label %lor.end
|
|
|
|
; CHECK: i8 92, label %lor.end
|
|
|
|
; CHECK: ]
|
|
|
|
}
|
|
|
|
|