forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* working optimization to get rid of extra xor * cleanup and added negative test case in addition to the positive test case * removed unrelated changes * added brackets for avoiding variable name collisions
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
llvm/test/Transforms/InstCombine/select-specific-transform.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; RUN: opt -passes=instcombine -S < %s | FileCheck %s | ||
|
||
; ----------------- POSITIVE TEST CASE ----------------- | ||
|
||
define i32 @src(i32 %x, i32 %y) { | ||
%xor1 = xor i32 %y, %x | ||
%cmp = icmp eq i32 %xor1, -1 | ||
%sel = select i1 %cmp, i32 %y, i32 0 | ||
%xor2 = xor i32 %sel, %x | ||
ret i32 %xor2 | ||
} | ||
|
||
; CHECK: %xor1 = xor i32 %y, %x | ||
; CHECK: %cmp = icmp eq i32 %xor1, -1 | ||
; CHECK: %xor2 = select i1 %cmp, i32 -1, i32 %x | ||
; CHECK-NOT: %xor2 = xor i32 %sel, %x | ||
; CHECK: ret i32 %xor2 | ||
|
||
; ----------------- NEGATIVE TEST CASE ----------------- | ||
|
||
define i32 @src2(i32 %x, i32 %y) { | ||
%xor1 = xor i32 %y, %x | ||
%cmp = icmp eq i32 %xor1, -2 | ||
%sel = select i1 %cmp, i32 %y, i32 0 | ||
%xor2 = xor i32 %sel, %x | ||
ret i32 %xor2 | ||
} | ||
|
||
; CHECK: %xor1 = xor i32 %y, %x | ||
; CHECK: %cmp = icmp eq i32 %xor1, -2 | ||
; CHECK: %sel = select i1 %cmp, i32 %y, i32 0 | ||
; CHECK: %xor2 = xor i32 %sel, %x | ||
; CHECK: ret i32 %xor2 |