diff options
| author | Weiming Zhao <weimingz@codeaurora.org> | 2016-07-29 23:33:48 +0000 |
|---|---|---|
| committer | Weiming Zhao <weimingz@codeaurora.org> | 2016-07-29 23:33:48 +0000 |
| commit | 812fde3603490eb140eb3ef29341dfe0d4e43c66 (patch) | |
| tree | 39708b6c117bb08a3a9c9bf4a9f334fd58ce2050 /llvm/test/CodeGen/ARM | |
| parent | 6ecbd16f008b7c18d871f5850dae30b0dc4889ed (diff) | |
| download | bcm5719-llvm-812fde3603490eb140eb3ef29341dfe0d4e43c66.tar.gz bcm5719-llvm-812fde3603490eb140eb3ef29341dfe0d4e43c66.zip | |
DAG: avoid duplicated truncating for sign extended operand
Summary:
When performing cmp for EQ/NE and the operand is sign extended, we can
avoid the truncaton if the bits to be tested are no less than origianl
bits.
Reviewers: eli.friedman
Subscribers: eli.friedman, aemerson, nemanjai, t.p.northover, llvm-commits
Differential Revision: https://reviews.llvm.org/D22933
llvm-svn: 277252
Diffstat (limited to 'llvm/test/CodeGen/ARM')
| -rw-r--r-- | llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll | 10 | ||||
| -rw-r--r-- | llvm/test/CodeGen/ARM/no_redundant_trunc_for_cmp.ll | 105 |
2 files changed, 112 insertions, 3 deletions
diff --git a/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll b/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll index cb608fc18d9..93572b1e63d 100644 --- a/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll +++ b/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll @@ -501,9 +501,13 @@ declare i32 @someVariadicFunc(i32, ...) ; ; CHECK-LABEL: noreturn: ; DISABLE: push -; -; CHECK: tst{{(\.w)?}} r0, #255 -; CHECK-NEXT: bne [[ABORT:LBB[0-9_]+]] +; ARM-ENABLE: cmp r0, #0 +; ARM-DISABLE: cmp r0, #0 +; ARM-ENABLE: bne [[ABORT:LBB[0-9_]+]] +; ARM-DISABLE: bne [[ABORT:LBB[0-9_]+]] +; THUMB-ENABLE: cbnz r0, [[ABORT:LBB[0-9_]+]] +; THUMB-DISABLE: cbnz r0, [[ABORT:LBB[0-9_]+]] + ; ; CHECK: mov{{s?}} r0, #42 ; diff --git a/llvm/test/CodeGen/ARM/no_redundant_trunc_for_cmp.ll b/llvm/test/CodeGen/ARM/no_redundant_trunc_for_cmp.ll new file mode 100644 index 00000000000..7146c09ee80 --- /dev/null +++ b/llvm/test/CodeGen/ARM/no_redundant_trunc_for_cmp.ll @@ -0,0 +1,105 @@ +; This test check if redundant truncate for eq/ne cmp is skipped during code gen. +;RUN: llc -mtriple=thumbv7-eabi < %s | FileCheck %s + +define void @test_zero(i16 signext %x) optsize { +;CHECK-LABEL: test_zero +entry: + %tobool = icmp eq i16 %x, 0 + br i1 %tobool, label %if.else, label %if.then +;CHECK-NOT: movw {{.*}}, #65535 +;CHECK: cbz r0, +if.then: ; preds = %entry + tail call void bitcast (void (...)* @foo1 to void ()*)() + br label %if.end + +if.else: ; preds = %entry + tail call void bitcast (void (...)* @foo2 to void ()*)() + br label %if.end + +if.end: ; preds = %if.else, %if.then + ret void +} + +define void @test_i8_nonzero(i18 signext %x) optsize { +;CHECK-LABEL: test_i8_nonzero +entry: + %tobool = icmp eq i18 %x, 150 + br i1 %tobool, label %if.else, label %if.then +;CHECK-NOT: bfc +;CHECK: cmp r{{[0-9]+}}, #150 +if.then: ; preds = %entry + tail call void bitcast (void (...)* @foo1 to void ()*)() + br label %if.end + +if.else: ; preds = %entry + tail call void bitcast (void (...)* @foo2 to void ()*)() + br label %if.end + +if.end: ; preds = %if.else, %if.then + ret void +} + +define void @test_i8_i16(i8 signext %x) optsize { +;CHECK-LABEL: test_i8_i16 +entry: + %x16 = sext i8 %x to i16 + %tobool = icmp eq i16 %x16, 300 + br i1 %tobool, label %if.else, label %if.then +;CHECK-NOT: uxth r0, r0 +;CHECK: cmp.w r0, #300 +if.then: ; preds = %entry + tail call void bitcast (void (...)* @foo1 to void ()*)() + br label %if.end + +if.else: ; preds = %entry + tail call void bitcast (void (...)* @foo2 to void ()*)() + br label %if.end + +if.end: ; preds = %if.else, %if.then + ret void +} + +define void @test_i16_i8(i16 signext %x) optsize { +;CHECK-LABEL: test_i16_i8 +entry: +;CHECK: uxtb [[REG:r[0-9+]]], r0 +;CHECK: cmp [[REG]], #128 + %x8 = trunc i16 %x to i8 + %tobool = icmp eq i8 %x8, 128 + br i1 %tobool, label %if.else, label %if.then +if.then: ; preds = %entry + tail call void bitcast (void (...)* @foo1 to void ()*)() + br label %if.end + +if.else: ; preds = %entry + tail call void bitcast (void (...)* @foo2 to void ()*)() + br label %if.end + +if.end: ; preds = %if.else, %if.then + ret void +} + +define void @test_zext_zero(i16 zeroext %x) optsize { +;CHECK-LABEL: test_zext_zero +entry: + %tobool = icmp eq i16 %x, 0 + br i1 %tobool, label %if.else, label %if.then +;CHECK-NOT: movw {{.*}}, #65535 +;CHECK: cbz r0, +if.then: ; preds = %entry + tail call void bitcast (void (...)* @foo1 to void ()*)() + br label %if.end + +if.else: ; preds = %entry + tail call void bitcast (void (...)* @foo2 to void ()*)() + br label %if.end + +if.end: ; preds = %if.else, %if.then + ret void +} + + +declare void @foo1(...) +declare void @foo2(...) + + |

