blob: af65ade35ce8d6411c9ad7bc5ef841d005d15cff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
; Test for DAG combine: fold (not (sub Y, X)) -> (add X, ~Y)
; when Y is a constant.
; Test case 1: Y is a constant - should transform to (add X, ~Y)
define i32 @test_not_sub_constant(i32 %x) {
; CHECK-LABEL: test_not_sub_constant:
; CHECK: # %bb.0:
; CHECK: leal -101(%rdi), %eax
; CHECK-NEXT: retq
%sub = sub i32 100, %x
%not = xor i32 %sub, -1
ret i32 %not
}
; Test case 2: Y is not a constant - should NOT optimize
define i32 @test_not_sub_non_constant(i32 %x, i32 %y) {
; CHECK-LABEL: test_not_sub_non_constant:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %esi, %eax
; CHECK-NEXT: subl %edi, %eax
; CHECK-NEXT: notl %eax
; CHECK-NEXT: retq
%sub = sub i32 %y, %x
%not = xor i32 %sub, -1
ret i32 %not
}
|