-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] Queue Xor for deletion after replacing its uses in free…
- Loading branch information
Showing
2 changed files
with
29 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
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,27 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt -passes=instcombine -S < %s | FileCheck %s | ||
|
||
define i32 @widget(i32 %arg, i32 %arg1) { | ||
; CHECK-LABEL: define i32 @widget( | ||
; CHECK-SAME: i32 [[ARG:%.*]], i32 [[ARG1:%.*]]) { | ||
; CHECK-NEXT: bb: | ||
; CHECK-NEXT: [[ICMP:%.*]] = icmp ne i32 [[ARG]], 0 | ||
; CHECK-NEXT: [[TMP0:%.*]] = zext i1 [[ICMP]] to i32 | ||
; CHECK-NEXT: [[MUL:%.*]] = shl nuw nsw i32 20, [[TMP0]] | ||
; CHECK-NEXT: [[XOR:%.*]] = zext i1 [[ICMP]] to i32 | ||
; CHECK-NEXT: [[ADD9:%.*]] = or i32 [[MUL]], [[XOR]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = zext i1 [[ICMP]] to i32 | ||
; CHECK-NEXT: [[MUL2:%.*]] = shl nuw nsw i32 [[ADD9]], [[TMP1]] | ||
; CHECK-NEXT: ret i32 [[MUL2]] | ||
; | ||
bb: | ||
%icmp = icmp eq i32 %arg, 0 | ||
%zext = zext i1 %icmp to i32 | ||
%sub = sub i32 2, %zext | ||
%mul = mul i32 20, %sub | ||
%zext8 = zext i1 %icmp to i32 | ||
%xor = xor i32 %zext8, 1 | ||
%add9 = add i32 %mul, %xor | ||
%mul2 = mul i32 %add9, %sub | ||
ret i32 %mul2 | ||
} |