30 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s3 4; Test for DAG combine: fold (not (sub Y, X)) -> (add X, ~Y)5; when Y is a constant.6 7; Test case 1: Y is a constant - should transform to (add X, ~Y)8define i32 @test_not_sub_constant(i32 %x) {9; CHECK-LABEL: test_not_sub_constant:10; CHECK: # %bb.0:11; CHECK: leal -101(%rdi), %eax12; CHECK-NEXT: retq13 %sub = sub i32 100, %x14 %not = xor i32 %sub, -115 ret i32 %not16}17 18; Test case 2: Y is not a constant - should NOT optimize19define i32 @test_not_sub_non_constant(i32 %x, i32 %y) {20; CHECK-LABEL: test_not_sub_non_constant:21; CHECK: # %bb.0:22; CHECK-NEXT: movl %esi, %eax23; CHECK-NEXT: subl %edi, %eax24; CHECK-NEXT: notl %eax25; CHECK-NEXT: retq26 %sub = sub i32 %y, %x27 %not = xor i32 %sub, -128 ret i32 %not29}30