# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -mtriple x86_64 -run-pass=x86-prelegalizer-combiner %s -o - | FileCheck %s # RUN: llc -mtriple x86_64 -passes=x86-prelegalizer-combiner-pass %s -o - | FileCheck %s --- name: dont_fold_sub tracksRegLiveness: true body: | bb.1.entry: liveins: $eax ; Not an identity, no folding. ; CHECK-LABEL: name: dont_fold_sub ; CHECK: liveins: $eax ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: %x:_(s32) = COPY $eax ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1 ; CHECK-NEXT: %op:_(s32) = G_ADD %x, [[C]] ; CHECK-NEXT: $eax = COPY %op(s32) ; CHECK-NEXT: RET implicit $eax %x:_(s32) = COPY $eax %cst:_(s32) = G_CONSTANT i32 1 %op:_(s32) = G_SUB %x(s32), %cst $eax = COPY %op(s32) RET implicit $eax ... --- name: sub_to_add tracksRegLiveness: true body: | bb.1.entry: liveins: $eax ; CHECK-LABEL: name: sub_to_add ; CHECK: liveins: $eax ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: %x:_(s32) = COPY $eax ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1 ; CHECK-NEXT: %op:_(s32) = G_ADD %x, [[C]] ; CHECK-NEXT: $eax = COPY %op(s32) ; CHECK-NEXT: RET implicit $eax %x:_(s32) = COPY $eax %cst:_(s32) = G_CONSTANT i32 1 %op:_(s32) = G_SUB %x(s32), %cst $eax = COPY %op(s32) RET implicit $eax ... --- name: sub_to_add_nuw tracksRegLiveness: true body: | bb.1.entry: liveins: $eax ; CHECK-LABEL: name: sub_to_add_nuw ; CHECK: liveins: $eax ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: %x:_(s32) = COPY $eax ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1 ; CHECK-NEXT: %op:_(s32) = G_ADD %x, [[C]] ; CHECK-NEXT: $eax = COPY %op(s32) ; CHECK-NEXT: RET implicit $eax %x:_(s32) = COPY $eax %cst:_(s32) = G_CONSTANT i32 1 %op:_(s32) = nuw G_SUB %x(s32), %cst $eax = COPY %op(s32) RET implicit $eax ... --- name: sub_to_add_nsw_128 body: | bb.0: liveins: $eax, $ebx ; CHECK-LABEL: name: sub_to_add_nsw_128 ; CHECK: liveins: $eax, $ebx ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: %a:_(s32) = COPY $eax ; CHECK-NEXT: %b:_(s8) = G_TRUNC %a(s32) ; CHECK-NEXT: %c:_(s8) = G_CONSTANT i8 -128 ; CHECK-NEXT: %add:_(s8) = G_ADD %b, %c ; CHECK-NEXT: %d:_(s32) = G_ZEXT %add(s8) ; CHECK-NEXT: $eax = COPY %d(s32) ; CHECK-NEXT: RET implicit $rax %a:_(s32) = COPY $eax %b:_(s8) = G_TRUNC %a %c:_(s8) = G_CONSTANT i8 -128 %add:_(s8) = nsw nuw G_SUB %b, %c %d:_(s32) = G_ZEXT %add $eax = COPY %d RET implicit $rax ... --- name: sub_to_add_nsw_intmin body: | bb.0: liveins: $eax, $ebx ; CHECK-LABEL: name: sub_to_add_nsw_intmin ; CHECK: liveins: $eax, $ebx ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: %a:_(s32) = COPY $eax ; CHECK-NEXT: %c:_(s32) = G_CONSTANT i32 -2147483648 ; CHECK-NEXT: %add:_(s32) = G_ADD %a, %c ; CHECK-NEXT: $eax = COPY %add(s32) ; CHECK-NEXT: RET implicit $rax %a:_(s32) = COPY $eax %c:_(s32) = G_CONSTANT i32 -2147483648 %add:_(s32) = nsw nuw G_SUB %a, %c $eax = COPY %add RET implicit $rax ...