Skip to content

Commit 0c05324

Browse files
committed
[InstCombine] Add test case for turning sub into xor using dominating condition. NFC
I plan to disable using dominating conditions for turning sub into xor, but first we need that demonstrates it currently happens.
1 parent 6a85cf8 commit 0c05324

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/test/Transforms/InstCombine/sub-xor.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,26 @@ define <2 x i8> @xor_add_splat_undef(<2 x i8> %x) {
157157
%add = add <2 x i8> %xor, <i8 42, i8 42>
158158
ret <2 x i8> %add
159159
}
160+
161+
define i32 @xor_dominating_cond(i32 %x) {
162+
; CHECK-LABEL: @xor_dominating_cond(
163+
; CHECK-NEXT: entry:
164+
; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[X:%.*]], 256
165+
; CHECK-NEXT: br i1 [[COND]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
166+
; CHECK: if.then:
167+
; CHECK-NEXT: [[A:%.*]] = xor i32 [[X]], 255
168+
; CHECK-NEXT: ret i32 [[A]]
169+
; CHECK: if.end:
170+
; CHECK-NEXT: ret i32 [[X]]
171+
;
172+
entry:
173+
%cond = icmp ult i32 %x, 256
174+
br i1 %cond, label %if.then, label %if.end
175+
176+
if.then:
177+
%a = sub i32 255, %x
178+
ret i32 %a
179+
180+
if.end:
181+
ret i32 %x
182+
}

0 commit comments

Comments
 (0)