diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-04-08 16:51:49 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-04-08 16:51:49 +0000 |
commit | 56737722e43464b896b9e7e628a8c3ce841da605 (patch) | |
tree | 5b27438b2d70b1bc1fa4388087e981498e17985b /llvm/test/Transforms | |
parent | 6d6d6af2263c917c2f9a4b8260dbac4d7c6e07b4 (diff) | |
download | bcm5719-llvm-56737722e43464b896b9e7e628a8c3ce841da605.tar.gz bcm5719-llvm-56737722e43464b896b9e7e628a8c3ce841da605.zip |
[InstCombine] Fix miscompile in FoldSPFofSPF
We had a select of a cast of a select but attempted to replace the outer
select with the inner select dispite their incompatible types.
Patch by Anton Korobeynikov!
This fixes PR27236.
llvm-svn: 265805
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstCombine/pr27236.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/pr27236.ll b/llvm/test/Transforms/InstCombine/pr27236.ll new file mode 100644 index 00000000000..0b086cd7b8c --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr27236.ll @@ -0,0 +1,19 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s + +define float @test1(i32 %scale) { +entry: + %tmp1 = icmp sgt i32 1, %scale + %tmp2 = select i1 %tmp1, i32 1, i32 %scale + %tmp3 = sitofp i32 %tmp2 to float + %tmp4 = icmp sgt i32 %tmp2, 0 + %sel = select i1 %tmp4, float %tmp3, float 0.000000e+00 + ret float %sel +} + +; CHECK-LABEL: define float @test1( +; CHECK: %[[tmp1:.*]] = icmp slt i32 %scale, 1 +; CHECK: %[[tmp2:.*]] = select i1 %[[tmp1]], i32 1, i32 %scale +; CHECK: %[[tmp3:.*]] = sitofp i32 %[[tmp2]] to float +; CHECK: %[[tmp4:.*]] = icmp sgt i32 %[[tmp2]], 0 +; CHECK: %[[sel:.*]] = select i1 %[[tmp4]], float %[[tmp3]], float 0.000000e+00 +; CHECK: ret float %[[sel]] |