mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Add an instcombine for constructs like a | -(b != c); a select is more
canonical, and generally leads to better code. Found while looking at an article about saturating arithmetic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129545 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -390,3 +390,22 @@ define i1 @test36(i32 %x) {
|
||||
; CHECK-NEXT: ret i1
|
||||
}
|
||||
|
||||
define i32 @test37(i32* %xp, i32 %y) {
|
||||
; CHECK: @test37
|
||||
; CHECK: select i1 %tobool, i32 -1, i32 %x
|
||||
%tobool = icmp ne i32 %y, 0
|
||||
%sext = sext i1 %tobool to i32
|
||||
%x = load i32* %xp
|
||||
%or = or i32 %sext, %x
|
||||
ret i32 %or
|
||||
}
|
||||
|
||||
define i32 @test38(i32* %xp, i32 %y) {
|
||||
; CHECK: @test38
|
||||
; CHECK: select i1 %tobool, i32 -1, i32 %x
|
||||
%tobool = icmp ne i32 %y, 0
|
||||
%sext = sext i1 %tobool to i32
|
||||
%x = load i32* %xp
|
||||
%or = or i32 %x, %sext
|
||||
ret i32 %or
|
||||
}
|
||||
|
Reference in New Issue
Block a user